'''simple docstring'''




# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import yaml

from ...utils import ComputeEnvironment, DistributedType, SageMakerDistributedType
from ...utils.constants import SAGEMAKER_PYTHON_VERSION, SAGEMAKER_PYTORCH_VERSION, SAGEMAKER_TRANSFORMERS_VERSION


__lowercase				   =  os.path.expanduser(
    os.getenv('''HF_HOME''', os.path.join(os.getenv('''XDG_CACHE_HOME''', '''~/.cache'''), '''huggingface'''))
)
__lowercase				   =  os.path.join(hf_cache_home, '''accelerate''')
__lowercase				   =  os.path.join(cache_dir, '''default_config.yaml''')
__lowercase				   =  os.path.join(cache_dir, '''default_config.yaml''')

# For backward compatibility: the default config is the json one if it's the only existing file.
if os.path.isfile(default_yaml_config_file) or not os.path.isfile(default_json_config_file):
						__lowercase				   =  default_yaml_config_file
else:
						__lowercase				   =  default_json_config_file






def     snake_case__							(      _A: Tuple			)   ->     Optional[Any]:

		'''simple docstring'''


		if config_file is not None:
				if not os.path.isfile(_A			):
						raise FileNotFoundError(
						    f"The passed configuration file `{config_file}` does not exist. "
						    """Please pass an existing file to `accelerate launch`, or use the the default one """
						    """created through `accelerate config` and run `accelerate launch` """
						    """without the `--config_file` argument."""			)
		else:
				lowerCAmelCase        =  default_config_file
		with open(_A				,       """r"""				,       encoding="""utf-8"""			) as f:
				if config_file.endswith(""".json"""			):
						if (
						    json.load(_A			).get("""compute_environment"""				,       ComputeEnvironment.LOCAL_MACHINE			)
						    == ComputeEnvironment.LOCAL_MACHINE
						):
								lowerCAmelCase        =  ClusterConfig
						else:
								lowerCAmelCase        =  SageMakerConfig
						return config_class.from_json_file(json_file=_A			)
				else:
						if (
						    yaml.safe_load(_A			).get("""compute_environment"""				,       ComputeEnvironment.LOCAL_MACHINE			)
						    == ComputeEnvironment.LOCAL_MACHINE
						):
								lowerCAmelCase        =  ClusterConfig
						else:
								lowerCAmelCase        =  SageMakerConfig
						return config_class.from_yaml_file(yaml_file=_A			)






@dataclass
class     a__:


			'''simple docstring'''






			UpperCAmelCase_      :					ComputeEnvironment
			UpperCAmelCase_      :					Union[DistributedType, SageMakerDistributedType]
			UpperCAmelCase_      :					str
			UpperCAmelCase_      :					bool



			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  self.__dict__
					# For serialization, it's best to convert Enums to strings (or their underlying value type).
					for key, value in result.items():
							if isinstance(__lowerCAmelCase	,   __lowerCAmelCase):
									lowerCAmelCase        =  value.value
							if isinstance(__lowerCAmelCase	,   __lowerCAmelCase) and not bool(__lowerCAmelCase):
									lowerCAmelCase        =  None
					lowerCAmelCase        =  {k: v for k, v in result.items() if v is not None}
					return result



			@classmethod
			def 							a_	(       cls	,   __lowerCAmelCase=None):




					"""simple docstring"""


					lowerCAmelCase        =  default_json_config_file if json_file is None else json_file
					with open(__lowerCAmelCase	,   """r"""	,   encoding="""utf-8""") as f:
							lowerCAmelCase        =  json.load(__lowerCAmelCase)
					if "compute_environment" not in config_dict:
							lowerCAmelCase        =  ComputeEnvironment.LOCAL_MACHINE
					if "mixed_precision" not in config_dict:
							lowerCAmelCase        =  """fp16""" if ("""fp16""" in config_dict and config_dict["""fp16"""]) else None
					if "fp16" in config_dict:  # Convert the config to the new format.
							del config_dict["fp16"]
					if "dynamo_backend" in config_dict:  # Convert the config to the new format.
							lowerCAmelCase        =  config_dict.pop("""dynamo_backend""")
							lowerCAmelCase        =  {} if dynamo_backend == """NO""" else {"""dynamo_backend""": dynamo_backend}
					if "use_cpu" not in config_dict:
							lowerCAmelCase        =  False
					return cls(**__lowerCAmelCase)



			def 							a_	(       self	,   __lowerCAmelCase):




					"""simple docstring"""


					with open(__lowerCAmelCase	,   """w"""	,   encoding="""utf-8""") as f:
							lowerCAmelCase        =  json.dumps(self.to_dict()	,   indent=2	,   sort_keys=__lowerCAmelCase) + """\n"""
							f.write(__lowerCAmelCase)



			@classmethod
			def 							a_	(       cls	,   __lowerCAmelCase=None):




					"""simple docstring"""


					lowerCAmelCase        =  default_yaml_config_file if yaml_file is None else yaml_file
					with open(__lowerCAmelCase	,   """r"""	,   encoding="""utf-8""") as f:
							lowerCAmelCase        =  yaml.safe_load(__lowerCAmelCase)
					if "compute_environment" not in config_dict:
							lowerCAmelCase        =  ComputeEnvironment.LOCAL_MACHINE

					if "mixed_precision" not in config_dict:
							lowerCAmelCase        =  """fp16""" if ("""fp16""" in config_dict and config_dict["""fp16"""]) else None
					if isinstance(config_dict["""mixed_precision"""]	,   __lowerCAmelCase) and not config_dict["mixed_precision"]:
							lowerCAmelCase        =  """no"""
					if "fp16" in config_dict:  # Convert the config to the new format.
							del config_dict["fp16"]
					if "dynamo_backend" in config_dict:  # Convert the config to the new format.
							lowerCAmelCase        =  config_dict.pop("""dynamo_backend""")
							lowerCAmelCase        =  {} if dynamo_backend == """NO""" else {"""dynamo_backend""": dynamo_backend}
					if "use_cpu" not in config_dict:
							lowerCAmelCase        =  False
					return cls(**__lowerCAmelCase)



			def 							a_	(       self	,   __lowerCAmelCase):




					"""simple docstring"""


					with open(__lowerCAmelCase	,   """w"""	,   encoding="""utf-8""") as f:
							yaml.safe_dump(self.to_dict()	,   __lowerCAmelCase)







			def 							a_	(       self):




					"""simple docstring"""


					if isinstance(self.compute_environment	,   __lowerCAmelCase):
							lowerCAmelCase        =  ComputeEnvironment(self.compute_environment)
					if isinstance(self.distributed_type	,   __lowerCAmelCase):
							if self.compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
									lowerCAmelCase        =  SageMakerDistributedType(self.distributed_type)
							else:
									lowerCAmelCase        =  DistributedType(self.distributed_type)
					if self.dynamo_config is None:
							lowerCAmelCase        =  {}







@dataclass
class     a__( lowerCAmelCase__     ):


			'''simple docstring'''






			UpperCAmelCase_      :					int
			UpperCAmelCase_      :					int								=	0
			UpperCAmelCase_      :					int								=	1
			UpperCAmelCase_      :					Optional[str]								=	None
			UpperCAmelCase_      :					Optional[str]								=	None
			UpperCAmelCase_      :					Optional[int]								=	None
			UpperCAmelCase_      :					Optional[str]								=	"static"
			UpperCAmelCase_      :					Optional[bool]								=	False
			UpperCAmelCase_      :					str								=	"main"

			# args for deepspeed_plugin
			UpperCAmelCase_      :					dict								=	None
			# args for fsdp
			UpperCAmelCase_      :					dict								=	None
			# args for megatron_lm
			UpperCAmelCase_      :					dict								=	None
			# args for ipex
			UpperCAmelCase_      :					dict								=	None
			# args for TPU
			UpperCAmelCase_      :					bool								=	False

			# args for TPU pods
			UpperCAmelCase_      :					str								=	None
			UpperCAmelCase_      :					str								=	None
			UpperCAmelCase_      :					bool								=	False
			UpperCAmelCase_      :					bool								=	False
			UpperCAmelCase_      :					str								=	None
			UpperCAmelCase_      :					List[str]								=	None
			UpperCAmelCase_      :					List[str]								=	None
			UpperCAmelCase_      :					List[str]								=	None

			# args for dynamo
			UpperCAmelCase_      :					dict								=	None



			def 							a_	(       self):




					"""simple docstring"""


					if self.deepspeed_config is None:
							lowerCAmelCase        =  {}
					if self.fsdp_config is None:
							lowerCAmelCase        =  {}
					if self.megatron_lm_config is None:
							lowerCAmelCase        =  {}
					if self.ipex_config is None:
							lowerCAmelCase        =  {}
					return super().__post_init__()







@dataclass
class     a__( lowerCAmelCase__     ):


			'''simple docstring'''






			UpperCAmelCase_      :					str
			UpperCAmelCase_      :					str
			UpperCAmelCase_      :					Optional[str]								=	None
			UpperCAmelCase_      :					Optional[str]								=	None
			UpperCAmelCase_      :					str								=	"us-east-1"
			UpperCAmelCase_      :					int								=	1
			UpperCAmelCase_      :					str								=	"all"
			UpperCAmelCase_      :					str								=	F'''accelerate-sagemaker-{num_machines}'''
			UpperCAmelCase_      :					str								=	SAGEMAKER_PYTORCH_VERSION
			UpperCAmelCase_      :					str								=	SAGEMAKER_TRANSFORMERS_VERSION
			UpperCAmelCase_      :					str								=	SAGEMAKER_PYTHON_VERSION
			UpperCAmelCase_      :					str								=	None
			UpperCAmelCase_      :					str								=	None
			UpperCAmelCase_      :					dict								=	None
			UpperCAmelCase_      :					dict								=	None





'''simple docstring'''




import os
import pickle
import tempfile
import unittest
from typing import Callable, Optional

import numpy as np

from transformers import (
    BatchEncoding,
    BertTokenizer,
    BertTokenizerFast,
    PreTrainedTokenizer,
    PreTrainedTokenizerFast,
    TensorType,
    TokenSpan,
    is_tokenizers_available,
)
from transformers.models.gpta.tokenization_gpta import GPTaTokenizer
from transformers.testing_utils import CaptureStderr, require_flax, require_tf, require_tokenizers, require_torch, slow


if is_tokenizers_available():
						from tokenizers import Tokenizer
						from tokenizers.models import WordPiece






class     a__( unittest.TestCase     ):


			'''simple docstring'''






			def 							a_	(       self	,   __lowerCAmelCase):




					"""simple docstring"""


					lowerCAmelCase        =  list(tokenizer_class.max_model_input_sizes.keys())
					for model_name in sa_models[:1]:
							lowerCAmelCase        =  tokenizer_class.from_pretrained(__lowerCAmelCase)
							self.assertIsNotNone(__lowerCAmelCase)
							self.assertIsInstance(__lowerCAmelCase	,   __lowerCAmelCase)
							self.assertIsInstance(__lowerCAmelCase	,   __lowerCAmelCase)

							for special_tok in tokenizer.all_special_tokens:
									self.assertIsInstance(__lowerCAmelCase	,   __lowerCAmelCase)
									lowerCAmelCase        =  tokenizer.convert_tokens_to_ids(__lowerCAmelCase)
									self.assertIsInstance(__lowerCAmelCase	,   __lowerCAmelCase)



			def 							a_	(       self	,   __lowerCAmelCase	,   __lowerCAmelCase = None):




					"""simple docstring"""


					lowerCAmelCase        =  pickle.dumps(__lowerCAmelCase)
					self.assertIsNotNone(__lowerCAmelCase)

					lowerCAmelCase        =  pickle.loads(__lowerCAmelCase)

					# Ensure is_fast is correctly restored
					self.assertEqual(be_restored.is_fast	,   be_original.is_fast)

					# Ensure encodings are potentially correctly restored
					if be_original.is_fast:
							self.assertIsNotNone(be_restored.encodings)
					else:
							self.assertIsNone(be_restored.encodings)

					# Ensure the keys are the same
					for original_v, restored_v in zip(be_original.values()	,   be_restored.values()):
							if equal_op:
									self.assertTrue(equal_op(__lowerCAmelCase	,   __lowerCAmelCase))
							else:
									self.assertEqual(__lowerCAmelCase	,   __lowerCAmelCase)



			@slow
			def 							a_	(       self):




					"""simple docstring"""


					self.check_tokenizer_from_pretrained(__lowerCAmelCase)



			def 							a_	(       self):




					"""simple docstring"""


					self.assertEqual(TensorType("""tf""")	,   TensorType.TENSORFLOW)
					self.assertEqual(TensorType("""pt""")	,   TensorType.PYTORCH)
					self.assertEqual(TensorType("""np""")	,   TensorType.NUMPY)



			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					import numpy as np

					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")
					lowerCAmelCase        =  BertTokenizerFast.from_pretrained("""bert-base-cased""")

					# Python no tensor
					with self.subTest("""BatchEncoding (Python, return_tensors=None)"""):
							self.assert_dump_and_restore(tokenizer_p("""Small example to encode"""))

					with self.subTest("""BatchEncoding (Python, return_tensors=NUMPY)"""):
							self.assert_dump_and_restore(
							    tokenizer_p("""Small example to encode"""	,   return_tensors=TensorType.NUMPY)	,   np.array_equal)

					with self.subTest("""BatchEncoding (Rust, return_tensors=None)"""):
							self.assert_dump_and_restore(tokenizer_r("""Small example to encode"""))

					with self.subTest("""BatchEncoding (Rust, return_tensors=NUMPY)"""):
							self.assert_dump_and_restore(
							    tokenizer_r("""Small example to encode"""	,   return_tensors=TensorType.NUMPY)	,   np.array_equal)



			@require_tf
			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					import tensorflow as tf

					def tf_array_equals(__lowerCAmelCase	,   __lowerCAmelCase):
							return tf.reduce_all(tf.equal(__lowerCAmelCase	,   __lowerCAmelCase))

					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")
					lowerCAmelCase        =  BertTokenizerFast.from_pretrained("""bert-base-cased""")

					with self.subTest("""BatchEncoding (Python, return_tensors=TENSORFLOW)"""):
							self.assert_dump_and_restore(
							    tokenizer_p("""Small example to encode"""	,   return_tensors=TensorType.TENSORFLOW)	,   __lowerCAmelCase)

					with self.subTest("""BatchEncoding (Rust, return_tensors=TENSORFLOW)"""):
							self.assert_dump_and_restore(
							    tokenizer_r("""Small example to encode"""	,   return_tensors=TensorType.TENSORFLOW)	,   __lowerCAmelCase)



			@require_torch
			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					import torch

					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")
					lowerCAmelCase        =  BertTokenizerFast.from_pretrained("""bert-base-cased""")

					with self.subTest("""BatchEncoding (Python, return_tensors=PYTORCH)"""):
							self.assert_dump_and_restore(
							    tokenizer_p("""Small example to encode"""	,   return_tensors=TensorType.PYTORCH)	,   torch.equal)

					with self.subTest("""BatchEncoding (Rust, return_tensors=PYTORCH)"""):
							self.assert_dump_and_restore(
							    tokenizer_r("""Small example to encode"""	,   return_tensors=TensorType.PYTORCH)	,   torch.equal)



			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")
					lowerCAmelCase        =  BertTokenizerFast.from_pretrained("""bert-base-cased""")

					with self.subTest("""Python Tokenizer"""):
							self.assertFalse(tokenizer_p("""Small example to_encode""").is_fast)

					with self.subTest("""Rust Tokenizer"""):
							self.assertTrue(tokenizer_r("""Small example to_encode""").is_fast)



			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BertTokenizerFast.from_pretrained("""bert-base-cased""")
					lowerCAmelCase        =  tokenizer_r(["""Test""", """\xad""", """test"""]	,   is_split_into_words=__lowerCAmelCase)

					self.assertEqual(encoded.word_to_tokens(0)	,   TokenSpan(start=1	,   end=2))
					self.assertEqual(encoded.word_to_tokens(1)	,   __lowerCAmelCase)
					self.assertEqual(encoded.word_to_tokens(2)	,   TokenSpan(start=2	,   end=3))



			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BatchEncoding({"""inputs""": [[1, 2, 3], [4, 5, 6]], """labels""": [0, 1]})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""np""")
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (2, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (2,))
					# test converting the converted
					with CaptureStderr() as cs:
							lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""np""")
					self.assertFalse(len(cs.err)	,   msg=f"should have no warning, but got {cs.err}")

					lowerCAmelCase        =  BatchEncoding({"""inputs""": [1, 2, 3], """labels""": 0})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""np"""	,   prepend_batch_axis=__lowerCAmelCase)
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (1, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (1,))



			@require_torch
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BatchEncoding({"""inputs""": [[1, 2, 3], [4, 5, 6]], """labels""": [0, 1]})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""pt""")
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (2, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (2,))
					# test converting the converted
					with CaptureStderr() as cs:
							lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""pt""")
					self.assertFalse(len(cs.err)	,   msg=f"should have no warning, but got {cs.err}")

					lowerCAmelCase        =  BatchEncoding({"""inputs""": [1, 2, 3], """labels""": 0})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""pt"""	,   prepend_batch_axis=__lowerCAmelCase)
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (1, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (1,))



			@require_tf
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BatchEncoding({"""inputs""": [[1, 2, 3], [4, 5, 6]], """labels""": [0, 1]})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""tf""")
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (2, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (2,))
					# test converting the converted
					with CaptureStderr() as cs:
							lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""tf""")
					self.assertFalse(len(cs.err)	,   msg=f"should have no warning, but got {cs.err}")

					lowerCAmelCase        =  BatchEncoding({"""inputs""": [1, 2, 3], """labels""": 0})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""tf"""	,   prepend_batch_axis=__lowerCAmelCase)
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (1, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (1,))



			@require_flax
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  BatchEncoding({"""inputs""": [[1, 2, 3], [4, 5, 6]], """labels""": [0, 1]})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""jax""")
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (2, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (2,))
					# test converting the converted
					with CaptureStderr() as cs:
							lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""jax""")
					self.assertFalse(len(cs.err)	,   msg=f"should have no warning, but got {cs.err}")

					lowerCAmelCase        =  BatchEncoding({"""inputs""": [1, 2, 3], """labels""": 0})
					lowerCAmelCase        =  batch.convert_to_tensors(tensor_type="""jax"""	,   prepend_batch_axis=__lowerCAmelCase)
					self.assertEqual(tensor_batch["""inputs"""].shape	,   (1, 3))
					self.assertEqual(tensor_batch["""labels"""].shape	,   (1,))



			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  [{"""input_ids""": np.array([0, 1, 2])}, {"""input_ids""": np.array([0, 1, 2, 3])}]
					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")

					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase)
					self.assertTrue(isinstance(batch["""input_ids"""]	,   np.ndarray))
					self.assertEqual(batch["""input_ids"""].tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])
					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase	,   return_tensors="""np""")
					self.assertTrue(isinstance(batch["""input_ids"""]	,   np.ndarray))
					self.assertEqual(batch["""input_ids"""].tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])



			@require_torch
			def 							a_	(       self):




					"""simple docstring"""


					import torch

					lowerCAmelCase        =  [{"""input_ids""": torch.tensor([0, 1, 2])}, {"""input_ids""": torch.tensor([0, 1, 2, 3])}]
					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")

					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase)
					self.assertTrue(isinstance(batch["""input_ids"""]	,   torch.Tensor))
					self.assertEqual(batch["""input_ids"""].tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])
					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase	,   return_tensors="""pt""")
					self.assertTrue(isinstance(batch["""input_ids"""]	,   torch.Tensor))
					self.assertEqual(batch["""input_ids"""].tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])



			@require_tf
			def 							a_	(       self):




					"""simple docstring"""


					import tensorflow as tf

					lowerCAmelCase        =  [{"""input_ids""": tf.constant([0, 1, 2])}, {"""input_ids""": tf.constant([0, 1, 2, 3])}]
					lowerCAmelCase        =  BertTokenizer.from_pretrained("""bert-base-cased""")

					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase)
					self.assertTrue(isinstance(batch["""input_ids"""]	,   tf.Tensor))
					self.assertEqual(batch["""input_ids"""].numpy().tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])
					lowerCAmelCase        =  tokenizer.pad(__lowerCAmelCase	,   padding=__lowerCAmelCase	,   return_tensors="""tf""")
					self.assertTrue(isinstance(batch["""input_ids"""]	,   tf.Tensor))
					self.assertEqual(batch["""input_ids"""].numpy().tolist()	,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]])



			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  Tokenizer(WordPiece(unk_token="""[UNK]"""))
					PreTrainedTokenizerFast(tokenizer_object=__lowerCAmelCase)







			@require_tokenizers
			def 							a_	(       self):




					"""simple docstring"""


					lowerCAmelCase        =  Tokenizer(WordPiece(unk_token="""[UNK]"""))
					with tempfile.TemporaryDirectory() as tmpdirname:
							bert_tokenizer.save(os.path.join(__lowerCAmelCase	,   """tokenizer.json"""))
							PreTrainedTokenizerFast(tokenizer_file=os.path.join(__lowerCAmelCase	,   """tokenizer.json"""))




