


'''simple docstring'''

import os
import sys
import unittest


lowercase__				     =		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_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
lowercase__				     =		os.path.join(git_repo_path, "src", "transformers")

lowercase__				     =		"\n{0} = None\n"

lowercase__				     =		"\nclass {0}(metaclass=DummyObject):\n    _backends = {1}\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, {1})\n"


lowercase__				     =		"\ndef {0}(*args, **kwargs):\n    requires_backends({0}, {1})\n"





class 						__SCREAMING_SNAKE_CASE					(      unittest.TestCase ):






     def  a_					(			self		)       ->    Optional[Any]:
          _a						=		find_backend("    _import_structure[\"models.albert\"].append(\"AlbertTokenizerFast\")"		)
          self.assertIsNone(__UpperCamelCase		)

          _a						=		find_backend("    if not is_tokenizers_available():"		)
          self.assertEqual(__UpperCamelCase     ,							"tokenizers"		)

          _a						=		find_backend("    if not is_tensorflow_text_available():"		)
          self.assertEqual(__UpperCamelCase     ,							"tensorflow_text"		)

          _a						=		find_backend("    if not (is_sentencepiece_available() and is_tokenizers_available()):"		)
          self.assertEqual(__UpperCamelCase     ,							"sentencepiece_and_tokenizers"		)

          _a						=		find_backend(
              "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"		)
          self.assertEqual(__UpperCamelCase     ,							"sentencepiece_and_tensorflow_text"		)

          _a						=		find_backend(
              "    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):"		)
          self.assertEqual(__UpperCamelCase     ,							"sentencepiece_and_tokenizers_and_vision"		)






     def  a_					(			self		)       ->    str:
          _a						=		read_init()
          # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
          self.assertIn("torch"     ,							__UpperCamelCase		)
          self.assertIn("tensorflow_text"     ,							__UpperCamelCase		)
          self.assertIn("sentencepiece_and_tokenizers"     ,							__UpperCamelCase		)

          # Likewise, we can't assert on the exact content of a key
          self.assertIn("BertModel"     ,							objects["torch"]		)
          self.assertIn("TFBertModel"     ,							objects["tf"]		)
          self.assertIn("FlaxBertModel"     ,							objects["flax"]		)
          self.assertIn("BertModel"     ,							objects["torch"]		)
          self.assertIn("TFBertTokenizer"     ,							objects["tensorflow_text"]		)
          self.assertIn("convert_slow_tokenizer"     ,							objects["sentencepiece_and_tokenizers"]		)






     def  a_					(			self		)       ->    List[Any]:
          _a						=		create_dummy_object("CONSTANT"     ,							"'torch'"		)
          self.assertEqual(__UpperCamelCase     ,							"\nCONSTANT = None\n"		)

          _a						=		create_dummy_object("function"     ,							"'torch'"		)
          self.assertEqual(
              __UpperCamelCase     ,							"\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"		)

          _a						=		"\nclass FakeClass(metaclass=DummyObject):\n    _backends = 'torch'\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, 'torch')\n"
          _a						=		create_dummy_object("FakeClass"     ,							"'torch'"		)
          self.assertEqual(__UpperCamelCase     ,							__UpperCamelCase		)






     def  a_					(			self		)       ->    Union[str, Any]:
          _a						=		"# This file is autogenerated by the command `make fix-copies`, do not edit.\nfrom ..utils import DummyObject, requires_backends\n\n\nCONSTANT = None\n\n\ndef function(*args, **kwargs):\n    requires_backends(function, [\"torch\"])\n\n\nclass FakeClass(metaclass=DummyObject):\n    _backends = [\"torch\"]\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, [\"torch\"])\n"
          _a						=		create_dummy_files({"torch": ["CONSTANT", "function", "FakeClass"]}		)
          self.assertEqual(dummy_files["torch"]     ,							__UpperCamelCase		)





'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase__				     =		logging.get_logger(__name__)

lowercase__				     =		{
    "YituTech/conv-bert-base": "https://huggingface.co/YituTech/conv-bert-base/resolve/main/config.json",
    "YituTech/conv-bert-medium-small": (
        "https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/config.json"
    ),
    "YituTech/conv-bert-small": "https://huggingface.co/YituTech/conv-bert-small/resolve/main/config.json",
    # See all ConvBERT models at https://huggingface.co/models?filter=convbert
}





class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''convbert'''






     def __init__(			self     ,							__UpperCamelCase=30_522     ,							__UpperCamelCase=768     ,							__UpperCamelCase=12     ,							__UpperCamelCase=12     ,							__UpperCamelCase=3_072     ,							__UpperCamelCase="gelu"     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=512     ,							__UpperCamelCase=2     ,							__UpperCamelCase=0.02     ,							__UpperCamelCase=1e-12     ,							__UpperCamelCase=1     ,							__UpperCamelCase=0     ,							__UpperCamelCase=2     ,							__UpperCamelCase=768     ,							__UpperCamelCase=2     ,							__UpperCamelCase=9     ,							__UpperCamelCase=1     ,							__UpperCamelCase=None     ,							**__UpperCamelCase     ,							)       ->    Optional[int]:
          super().__init__(
              pad_token_id=__UpperCamelCase     ,							bos_token_id=__UpperCamelCase     ,							eos_token_id=__UpperCamelCase     ,							**__UpperCamelCase     ,							)

          _a						=		vocab_size
          _a						=		hidden_size
          _a						=		num_hidden_layers
          _a						=		num_attention_heads
          _a						=		intermediate_size
          _a						=		hidden_act
          _a						=		hidden_dropout_prob
          _a						=		attention_probs_dropout_prob
          _a						=		max_position_embeddings
          _a						=		type_vocab_size
          _a						=		initializer_range
          _a						=		layer_norm_eps
          _a						=		embedding_size
          _a						=		head_ratio
          _a						=		conv_kernel_size
          _a						=		num_groups
          _a						=		classifier_dropout







class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):






     @property
     def  a_					(			self		)       ->    Mapping[str, Mapping[int, str]]:
          if self.task == "multiple-choice":
               _a						=		{0: "batch", 1: "choice", 2: "sequence"}
          else:
               _a						=		{0: "batch", 1: "sequence"}
          return OrderedDict(
              [
                  ("input_ids", dynamic_axis),
                  ("attention_mask", dynamic_axis),
                  ("token_type_ids", dynamic_axis),
              ]		)

