
import inspect
import tempfile
from collections import OrderedDict, UserDict
from collections.abc import MutableMapping
from contextlib import ExitStack, contextmanager
from dataclasses import fields
from enum import Enum
from typing import Any, ContextManager, List, Tuple

import numpy as np

from .import_utils import is_flax_available, is_tf_available, is_torch_available, is_torch_fx_proxy


if is_flax_available():
			import jax.numpy as jnp





class 			_lowerCAmelCase      (			__a ):




				def __get__(      self       ,       _UpperCamelCase       ,       _UpperCamelCase=None  )       ->   Optional[Any]:
							# See docs.python.org/3/howto/descriptor.html#properties
							if obj is None:
										return self
							if self.fget is None:
										raise AttributeError("unreadable attribute"  )
							lowerCAmelCase_      			=			"__cached_" + self.fget.__name__
							lowerCAmelCase_      			=			getattr(UpperCamelCase_       ,       UpperCamelCase_       ,       UpperCamelCase_  )
							if cached is None:
										lowerCAmelCase_      			=			self.fget(UpperCamelCase_  )
										setattr(UpperCamelCase_       ,       UpperCamelCase_       ,       UpperCamelCase_  )
							return cached






def      lowerCamelCase__       (       __lowerCAmelCase						:						Union[str, Any]       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			val.lower()
			if val in {"y", "yes", "t", "true", "on", "1"}:
						return 1
			if val in {"n", "no", "f", "false", "off", "0"}:
						return 0
			raise ValueError(F"""invalid truth value {val!r}"""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[Any]       ):




			"""simple docstring"""


			if is_torch_fx_proxy(lowerCamelCase__       ):
						return True
			if is_torch_available():
						import torch

						if isinstance(lowerCamelCase__					,							torch.Tensor       ):
									return True
			if is_tf_available():
						import tensorflow as tf

						if isinstance(lowerCamelCase__					,							tf.Tensor       ):
									return True

			if is_flax_available():
						import jax.numpy as jnp
						from jax.core import Tracer

						if isinstance(lowerCamelCase__					,							(jnp.ndarray, Tracer)       ):
									return True

			return isinstance(lowerCamelCase__					,							np.ndarray       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[Any]       ):




			"""simple docstring"""


			return isinstance(lowerCamelCase__					,							np.ndarray       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any       ):




			"""simple docstring"""


			return _is_numpy(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Union[str, Any]       ):




			"""simple docstring"""


			import torch

			return isinstance(lowerCamelCase__					,							torch.Tensor       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[str]       ):




			"""simple docstring"""


			return False if not is_torch_available() else _is_torch(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[int]       ):




			"""simple docstring"""


			import torch

			return isinstance(lowerCamelCase__					,							torch.device       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[int]       ):




			"""simple docstring"""


			return False if not is_torch_available() else _is_torch_device(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[int]       ):




			"""simple docstring"""


			import torch

			if isinstance(lowerCamelCase__					,							lowerCamelCase__       ):
						if hasattr(lowerCamelCase__					,							lowerCamelCase__       ):
									lowerCAmelCase_      			=			getattr(lowerCamelCase__					,							lowerCamelCase__       )
						else:
									return False
			return isinstance(lowerCamelCase__					,							torch.dtype       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any       ):




			"""simple docstring"""


			return False if not is_torch_available() else _is_torch_dtype(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Dict       ):




			"""simple docstring"""


			import tensorflow as tf

			return isinstance(lowerCamelCase__					,							tf.Tensor       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any       ):




			"""simple docstring"""


			return False if not is_tf_available() else _is_tensorflow(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[Any]       ):




			"""simple docstring"""


			import tensorflow as tf

			# the `is_symbolic_tensor` predicate is only available starting with TF 2.14
			if hasattr(lowerCamelCase__					,							"is_symbolic_tensor"       ):
						return tf.is_symbolic_tensor(lowerCamelCase__       )
			return type(lowerCamelCase__       ) == tf.Tensor






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[str]       ):




			"""simple docstring"""


			return False if not is_tf_available() else _is_tf_symbolic_tensor(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[Any]       ):




			"""simple docstring"""


			import jax.numpy as jnp  # noqa: F811

			return isinstance(lowerCamelCase__					,							jnp.ndarray       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[Any]       ):




			"""simple docstring"""


			return False if not is_flax_available() else _is_jax(lowerCamelCase__       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any       ):




			"""simple docstring"""


			if isinstance(lowerCamelCase__					,							(dict, UserDict)       ):
						return {k: to_py_obj(lowerCamelCase__       ) for k, v in obj.items()}
			elif isinstance(lowerCamelCase__					,							(list, tuple)       ):
						return [to_py_obj(lowerCamelCase__       ) for o in obj]
			elif is_tf_tensor(lowerCamelCase__       ):
						return obj.numpy().tolist()
			elif is_torch_tensor(lowerCamelCase__       ):
						return obj.detach().cpu().tolist()
			elif is_jax_tensor(lowerCamelCase__       ):
						return np.asarray(lowerCamelCase__       ).tolist()
			elif isinstance(lowerCamelCase__					,							(np.ndarray, np.number)       ):  # tolist also works on 0d np arrays
						return obj.tolist()
			else:
						return obj






def      lowerCamelCase__       (       __lowerCAmelCase						:						Dict       ):




			"""simple docstring"""


			if isinstance(lowerCamelCase__					,							(dict, UserDict)       ):
						return {k: to_numpy(lowerCamelCase__       ) for k, v in obj.items()}
			elif isinstance(lowerCamelCase__					,							(list, tuple)       ):
						return np.array(lowerCamelCase__       )
			elif is_tf_tensor(lowerCamelCase__       ):
						return obj.numpy()
			elif is_torch_tensor(lowerCamelCase__       ):
						return obj.detach().cpu().numpy()
			elif is_jax_tensor(lowerCamelCase__       ):
						return np.asarray(lowerCamelCase__       )
			else:
						return obj





class 			_lowerCAmelCase      (			__a ):




				def   __a		(      self  )       ->   Tuple:
							lowerCAmelCase_      			=			fields(self  )

							# Safety and consistency checks
							if not len(UpperCamelCase_  ):
										raise ValueError(f"""{self.__class__.__name__} has no fields."""  )
							if not all(field.default is None for field in class_fields[1:]  ):
										raise ValueError(f"""{self.__class__.__name__} should not have more than one required field."""  )

							lowerCAmelCase_      			=			getattr(self       ,       class_fields[0].name  )
							lowerCAmelCase_      			=			all(getattr(self       ,       field.name  ) is None for field in class_fields[1:]  )

							if other_fields_are_none and not is_tensor(UpperCamelCase_  ):
										if isinstance(UpperCamelCase_       ,       UpperCamelCase_  ):
													lowerCAmelCase_      			=			first_field.items()
													lowerCAmelCase_      			=			True
										else:
													try:
																lowerCAmelCase_      			=			iter(UpperCamelCase_  )
																lowerCAmelCase_      			=			True
													except TypeError:
																lowerCAmelCase_      			=			False

            # if we provided an iterator as first field and the iterator is a (key, value) iterator
            # set the associated fields
										if first_field_iterator:
													for idx, element in enumerate(UpperCamelCase_  ):
																if (
																    not isinstance(UpperCamelCase_       ,       (list, tuple)  )
																    or not len(UpperCamelCase_  ) == 2
																    or not isinstance(element[0]       ,       UpperCamelCase_  )
																):
																			if idx == 0:
																						# If we do not have an iterator of key/values, set it as attribute
																						lowerCAmelCase_      			=			first_field
																			else:
																						# If we have a mixed iterator, raise an error
																						raise ValueError(
																						    f"""Cannot set key/value for {element}. It needs to be a tuple (key, value)."""  )
																			break
																setattr(self       ,       element[0]       ,       element[1]  )
																if element[1] is not None:
																			lowerCAmelCase_      			=			element[1]
										elif first_field is not None:
													lowerCAmelCase_      			=			first_field
							else:
										for field in class_fields:
													lowerCAmelCase_      			=			getattr(self       ,       field.name  )
													if v is not None:
																lowerCAmelCase_      			=			v




				def __delitem__(      self       ,       *_UpperCamelCase       ,       **_UpperCamelCase  )       ->   str:
							raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""  )




				def   __a		(      self       ,       *_UpperCamelCase       ,       **_UpperCamelCase  )       ->   List[str]:
							raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""  )




				def   __a		(      self       ,       *_UpperCamelCase       ,       **_UpperCamelCase  )       ->   Dict:
							raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""  )




				def   __a		(      self       ,       *_UpperCamelCase       ,       **_UpperCamelCase  )       ->   Optional[Any]:
							raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""  )




				def __getitem__(      self       ,       _UpperCamelCase  )       ->   Tuple:
							if isinstance(UpperCamelCase_       ,       UpperCamelCase_  ):
										lowerCAmelCase_      			=			dict(self.items()  )
										return inner_dict[k]
							else:
										return self.to_tuple()[k]




				def __setattr__(      self       ,       _UpperCamelCase       ,       _UpperCamelCase  )       ->   int:
							if name in self.keys() and value is not None:
										# Don't call self.__setitem__ to avoid recursion errors
										super().__setitem__(UpperCamelCase_       ,       UpperCamelCase_  )
							super().__setattr__(UpperCamelCase_       ,       UpperCamelCase_  )




				def __setitem__(      self       ,       _UpperCamelCase       ,       _UpperCamelCase  )       ->   Optional[int]:
							# Will raise a KeyException if needed
							super().__setitem__(UpperCamelCase_       ,       UpperCamelCase_  )
							# Don't call self.__setattr__ to avoid recursion errors
							super().__setattr__(UpperCamelCase_       ,       UpperCamelCase_  )




				def   __a		(      self  )       ->   List[Any]:
							return tuple(self[k] for k in self.keys()  )





class 			_lowerCAmelCase      (			__a      ,   __a ):




				@classmethod
				def   __a		(      cls       ,       _UpperCamelCase  )       ->   Dict:
							raise ValueError(
							    f"""{value} is not a valid {cls.__name__}, please select one of {list(cls._valueamember_map_.keys()  )}"""  )





class 			_lowerCAmelCase      (			__a ):
				_lowercase    	="longest"
				_lowercase    	="max_length"
				_lowercase    	="do_not_pad"





class 			_lowerCAmelCase      (			__a ):
				_lowercase    	="pt"
				_lowercase    	="tf"
				_lowercase    	="np"
				_lowercase    	="jax"





class 			_lowerCAmelCase      :




				def __init__(      self       ,       _UpperCamelCase  )       ->   List[str]:
							lowerCAmelCase_      			=			context_managers
							lowerCAmelCase_      			=			ExitStack()




				def __enter__(      self  )       ->   Any:
							for context_manager in self.context_managers:
										self.stack.enter_context(UpperCamelCase_  )




				def __exit__(      self       ,       *_UpperCamelCase       ,       **_UpperCamelCase  )       ->   str:
							self.stack.__exit__(*UpperCamelCase_       ,       **UpperCamelCase_  )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Dict       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			infer_framework(lowerCamelCase__       )
			if framework == "tf":
						lowerCAmelCase_      			=			inspect.signature(model_class.call       )  # TensorFlow models
			elif framework == "pt":
						lowerCAmelCase_      			=			inspect.signature(model_class.forward       )  # PyTorch models
			else:
						lowerCAmelCase_      			=			inspect.signature(model_class.__call__       )  # Flax models

			for p in signature.parameters:
						if p == "return_loss" and signature.parameters[p].default is True:
									return True

			return False






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[str]       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			model_class.__name__
			lowerCAmelCase_      			=			infer_framework(lowerCamelCase__       )
			if framework == "tf":
						lowerCAmelCase_      			=			inspect.signature(model_class.call       )  # TensorFlow models
			elif framework == "pt":
						lowerCAmelCase_      			=			inspect.signature(model_class.forward       )  # PyTorch models
			else:
						lowerCAmelCase_      			=			inspect.signature(model_class.__call__       )  # Flax models

			if "QuestionAnswering" in model_name:
						return [p for p in signature.parameters if "label" in p or p in ("start_positions", "end_positions")]
			else:
						return [p for p in signature.parameters if "label" in p]






def      lowerCamelCase__       (       __lowerCAmelCase						:						Union[str, Any]					,							__lowerCAmelCase						:						Dict = ""					,							__lowerCAmelCase						:						List[Any] = "."       ):




			"""simple docstring"""


			def _flatten_dict(__lowerCAmelCase						:						Any					,							__lowerCAmelCase						:						List[str]=""					,							__lowerCAmelCase						:						Optional[int]="."       ):
						for k, v in d.items():
									lowerCAmelCase_      			=			str(lowerCamelCase__       ) + delimiter + str(lowerCamelCase__       ) if parent_key else k
									if v and isinstance(lowerCamelCase__					,							lowerCamelCase__       ):
												yield from flatten_dict(lowerCamelCase__					,							lowerCamelCase__					,							delimiter=lowerCamelCase__       ).items()
									else:
												yield key, v

			return dict(_flatten_dict(lowerCamelCase__					,							lowerCamelCase__					,							lowerCamelCase__       )       )






@contextmanager
def      lowerCamelCase__       (       __lowerCAmelCase						:						Optional[int]					,							__lowerCAmelCase						:						Optional[Any] = False       ):




			"""simple docstring"""


			if use_temp_dir:
						with tempfile.TemporaryDirectory() as tmp_dir:
									yield tmp_dir
			else:
						yield working_dir






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[Any]					,							__lowerCAmelCase						:						Dict=None       ):




			"""simple docstring"""


			if is_numpy_array(lowerCamelCase__       ):
						return np.transpose(lowerCamelCase__					,							axes=lowerCamelCase__       )
			elif is_torch_tensor(lowerCamelCase__       ):
						return array.T if axes is None else array.permute(*lowerCamelCase__       )
			elif is_tf_tensor(lowerCamelCase__       ):
						import tensorflow as tf

						return tf.transpose(lowerCamelCase__					,							perm=lowerCamelCase__       )
			elif is_jax_tensor(lowerCamelCase__       ):
						return jnp.transpose(lowerCamelCase__					,							axes=lowerCamelCase__       )
			else:
						raise ValueError(F"""Type not supported for transpose: {type(lowerCamelCase__       )}."""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						str					,							__lowerCAmelCase						:						Optional[int]       ):




			"""simple docstring"""


			if is_numpy_array(lowerCamelCase__       ):
						return np.reshape(lowerCamelCase__					,							lowerCamelCase__       )
			elif is_torch_tensor(lowerCamelCase__       ):
						return array.reshape(*lowerCamelCase__       )
			elif is_tf_tensor(lowerCamelCase__       ):
						import tensorflow as tf

						return tf.reshape(lowerCamelCase__					,							lowerCamelCase__       )
			elif is_jax_tensor(lowerCamelCase__       ):
						return jnp.reshape(lowerCamelCase__					,							lowerCamelCase__       )
			else:
						raise ValueError(F"""Type not supported for reshape: {type(lowerCamelCase__       )}."""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[Any]					,							__lowerCAmelCase						:						List[str]=None       ):




			"""simple docstring"""


			if is_numpy_array(lowerCamelCase__       ):
						return np.squeeze(lowerCamelCase__					,							axis=lowerCamelCase__       )
			elif is_torch_tensor(lowerCamelCase__       ):
						return array.squeeze() if axis is None else array.squeeze(dim=lowerCamelCase__       )
			elif is_tf_tensor(lowerCamelCase__       ):
						import tensorflow as tf

						return tf.squeeze(lowerCamelCase__					,							axis=lowerCamelCase__       )
			elif is_jax_tensor(lowerCamelCase__       ):
						return jnp.squeeze(lowerCamelCase__					,							axis=lowerCamelCase__       )
			else:
						raise ValueError(F"""Type not supported for squeeze: {type(lowerCamelCase__       )}."""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any					,							__lowerCAmelCase						:						Tuple       ):




			"""simple docstring"""


			if is_numpy_array(lowerCamelCase__       ):
						return np.expand_dims(lowerCamelCase__					,							lowerCamelCase__       )
			elif is_torch_tensor(lowerCamelCase__       ):
						return array.unsqueeze(dim=lowerCamelCase__       )
			elif is_tf_tensor(lowerCamelCase__       ):
						import tensorflow as tf

						return tf.expand_dims(lowerCamelCase__					,							axis=lowerCamelCase__       )
			elif is_jax_tensor(lowerCamelCase__       ):
						return jnp.expand_dims(lowerCamelCase__					,							axis=lowerCamelCase__       )
			else:
						raise ValueError(F"""Type not supported for expand_dims: {type(lowerCamelCase__       )}."""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						List[Any]       ):




			"""simple docstring"""


			if is_numpy_array(lowerCamelCase__       ):
						return np.size(lowerCamelCase__       )
			elif is_torch_tensor(lowerCamelCase__       ):
						return array.numel()
			elif is_tf_tensor(lowerCamelCase__       ):
						import tensorflow as tf

						return tf.size(lowerCamelCase__       )
			elif is_jax_tensor(lowerCamelCase__       ):
						return array.size
			else:
						raise ValueError(F"""Type not supported for expand_dims: {type(lowerCamelCase__       )}."""       )






def      lowerCamelCase__       (       __lowerCAmelCase						:						Any					,							__lowerCAmelCase						:						Dict       ):




			"""simple docstring"""


			for key, value in auto_map.items():
						if isinstance(lowerCamelCase__					,							(tuple, list)       ):
									lowerCAmelCase_      			=			[F"""{repo_id}--{v}""" if (v is not None and "--" not in v) else v for v in value]
						elif value is not None and "--" not in value:
									lowerCAmelCase_      			=			F"""{repo_id}--{value}"""

			return auto_map






def      lowerCamelCase__       (       __lowerCAmelCase						:						Tuple       ):




			"""simple docstring"""


			for base_class in inspect.getmro(lowerCamelCase__       ):
						lowerCAmelCase_      			=			base_class.__module__
						lowerCAmelCase_      			=			base_class.__name__
						if module.startswith("tensorflow"       ) or module.startswith("keras"       ) or name == "TFPreTrainedModel":
									return "tf"
						elif module.startswith("torch"       ) or name == "PreTrainedModel":
									return "pt"
						elif module.startswith("flax"       ) or module.startswith("jax"       ) or name == "FlaxPreTrainedModel":
									return "flax"
			else:
						raise TypeError(F"""Could not infer framework from class {model_class}."""       )





import os
import re
import shutil
import sys
import tempfile
import unittest

import black


_A     =  os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import check_copies  # noqa: E402


# This is the reference code that will be used in the tests.
# If BertLMPredictionHead is changed in modeling_bert.py, this code needs to be manually updated.
_A     =  "    def __init__(self, config):\n        super().__init__()\n        self.transform = BertPredictionHeadTransform(config)\n\n        # The output weights are the same as the input embeddings, but there is\n        # an output-only bias for each token.\n        self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False)\n\n        self.bias = nn.Parameter(torch.zeros(config.vocab_size))\n\n        # Need a link between the two variables so that the bias is correctly resized with `resize_token_embeddings`\n        self.decoder.bias = self.bias\n\n    def forward(self, hidden_states):\n        hidden_states = self.transform(hidden_states)\n        hidden_states = self.decoder(hidden_states)\n        return hidden_states\n"





class 			_lowerCAmelCase      (			unittest.TestCase ):




				def   __a		(      self  )       ->   Any:
							lowerCAmelCase_      			=			tempfile.mkdtemp()
							os.makedirs(os.path.join(self.transformer_dir       ,       "models/bert/"  )  )
							lowerCAmelCase_      			=			self.transformer_dir
							shutil.copy(
							    os.path.join(_UpperCamelCase       ,       "src/transformers/models/bert/modeling_bert.py"  )       ,       os.path.join(self.transformer_dir       ,       "models/bert/modeling_bert.py"  )       ,       )




				def   __a		(      self  )       ->   List[Any]:
							lowerCAmelCase_      			=			"src/transformers"
							shutil.rmtree(self.transformer_dir  )




				def   __a		(      self       ,       _UpperCamelCase       ,       _UpperCamelCase       ,       _UpperCamelCase       ,       _UpperCamelCase=None  )       ->   Optional[int]:
							lowerCAmelCase_      			=			comment + f"""\nclass {class_name}(nn.Module):\n""" + class_code
							if overwrite_result is not None:
										lowerCAmelCase_      			=			comment + f"""\nclass {class_name}(nn.Module):\n""" + overwrite_result
							lowerCAmelCase_      			=			black.Mode(target_versions={black.TargetVersion.PYaa}       ,       line_length=119  )
							lowerCAmelCase_      			=			black.format_str(_UpperCamelCase       ,       mode=_UpperCamelCase  )
							lowerCAmelCase_      			=			os.path.join(self.transformer_dir       ,       "new_code.py"  )
							with open(_UpperCamelCase       ,       "w"       ,       newline="\n"  ) as f:
										f.write(_UpperCamelCase  )
							if overwrite_result is None:
										self.assertTrue(len(check_copies.is_copy_consistent(_UpperCamelCase  )  ) == 0  )
							else:
										check_copies.is_copy_consistent(f.name       ,       overwrite=_UpperCamelCase  )
										with open(_UpperCamelCase       ,       "r"  ) as f:
													self.assertTrue(f.read()       ,       _UpperCamelCase  )




				def   __a		(      self  )       ->   Any:
							lowerCAmelCase_      			=			check_copies.find_code_in_transformers("models.bert.modeling_bert.BertLMPredictionHead"  )
							self.assertEqual(_UpperCamelCase       ,       _UpperCamelCase  )




				def   __a		(      self  )       ->   Any:
							# Base copy consistency
							self.check_copy_consistency(
							    "# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead"       ,       "BertLMPredictionHead"       ,       REFERENCE_CODE + "\n"       ,       )

							# With no empty line at the end
							self.check_copy_consistency(
							    "# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead"       ,       "BertLMPredictionHead"       ,       _UpperCamelCase       ,       )

							# Copy consistency with rename
							self.check_copy_consistency(
							    "# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel"       ,       "TestModelLMPredictionHead"       ,       re.sub("Bert"       ,       "TestModel"       ,       _UpperCamelCase  )       ,       )

							# Copy consistency with a really long name
							lowerCAmelCase_      			=			"TestModelWithAReallyLongNameBecauseSomePeopleLikeThatForSomeReason"
							self.check_copy_consistency(
							    f"""# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->{long_class_name}"""       ,       f"""{long_class_name}LMPredictionHead"""       ,       re.sub("Bert"       ,       _UpperCamelCase       ,       _UpperCamelCase  )       ,       )

							# Copy consistency with overwrite
							self.check_copy_consistency(
							    "# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel"       ,       "TestModelLMPredictionHead"       ,       _UpperCamelCase       ,       overwrite_result=re.sub("Bert"       ,       "TestModel"       ,       _UpperCamelCase  )       ,       )




				def   __a		(      self  )       ->   Any:
							lowerCAmelCase_      			=			check_copies.LOCALIZED_READMES["README_zh-hans.md"]

							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the"
							    " Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for"
							    " Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong"
							    " Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut.\n1."
							    " **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (from HuggingFace),"
							    " released together with the paper [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and"
							    " lighter](https://arxiv.org/abs/1910.01108) by Victor Sanh, Lysandre Debut and Thomas Wolf. The same"
							    " method has been applied to compress GPT2 into"
							    " [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into"
							    " [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),"
							    " Multilingual BERT into"
							    " [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German"
							    " version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)**"
							    " (from Google Research/Stanford University) released with the paper [ELECTRA: Pre-training text encoders"
							    " as discriminators rather than generators](https://arxiv.org/abs/2003.10555) by Kevin Clark, Minh-Thang"
							    " Luong, Quoc V. Le, Christopher D. Manning."
							)
							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"
							    " Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"
							    " Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"
							    " Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"
							)
							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"
							    " Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"
							    " Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"
							    " Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n1."
							    " **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (来自 HuggingFace) 伴随论文"
							    " [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and"
							    " lighter](https://arxiv.org/abs/1910.01108) 由 Victor Sanh, Lysandre Debut and Thomas Wolf 发布。 The same"
							    " method has been applied to compress GPT2 into"
							    " [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into"
							    " [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),"
							    " Multilingual BERT into"
							    " [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German"
							    " version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)** (来自"
							    " Google Research/Stanford University) 伴随论文 [ELECTRA: Pre-training text encoders as discriminators rather"
							    " than generators](https://arxiv.org/abs/2003.10555) 由 Kevin Clark, Minh-Thang Luong, Quoc V. Le,"
							    " Christopher D. Manning 发布。\n"
							)

							lowerCAmelCase_			,						lowerCAmelCase_      			=			check_copies.convert_to_localized_md(
							    _UpperCamelCase       ,       _UpperCamelCase       ,       localized_readme["format_model_list"]  )

							self.assertFalse(_UpperCamelCase  )
							self.assertEqual(_UpperCamelCase       ,       _UpperCamelCase  )

							lowerCAmelCase_			,						lowerCAmelCase_      			=			check_copies.convert_to_localized_md(
							    _UpperCamelCase       ,       _UpperCamelCase       ,       localized_readme["format_model_list"]  )

							# Check whether the number of models is equal to README.md after conversion.
							self.assertTrue(_UpperCamelCase  )

							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the"
							    " Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for"
							    " Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong"
							    " Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut."
							)
							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/main/model_doc/albert.html)** (来自 Google Research and"
							    " the Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"
							    " Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"
							    " Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"
							)
							lowerCAmelCase_      			=			(
							    "1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"
							    " Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"
							    " Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"
							    " Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"
							)

							lowerCAmelCase_			,						lowerCAmelCase_      			=			check_copies.convert_to_localized_md(
							    _UpperCamelCase       ,       _UpperCamelCase       ,       localized_readme["format_model_list"]  )

							# Check if the model link is synchronized.
							self.assertEqual(_UpperCamelCase       ,       _UpperCamelCase  )



