




'''simple docstring'''







from typing import Mapping

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


lowercase      :   Optional[Any]      =       logging.get_logger(__name__)

lowercase      :   str      =       {
    """google/umt5-small""": """https://huggingface.co/google/umt5-small/resolve/main/config.json""",
    # See all umt5 models at https://huggingface.co/models?filter=umt5
}







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Optional[Any]          =					"""umt5"""
     lowerCAmelCase_  :     Optional[int]          =					["""past_key_values"""]







     def __init__(				self							,__a=250_112							,__a=512							,__a=64							,__a=1_024							,__a=8							,__a=None							,__a=6							,__a=32							,__a=128							,__a=0.1							,__a=1E-6							,__a=1.0							,__a="gated-gelu"							,__a=True							,__a=True							,__a="T5Tokenizer"							,__a=True							,__a=0							,__a=1							,__a=0							,**__a							,)      ->				Optional[int]:
          super().__init__(
              is_encoder_decoder=__a							,tokenizer_class=__a							,tie_word_embeddings=__a							,pad_token_id=__a							,eos_token_id=__a							,decoder_start_token_id=__a							,**__a							,)
          snake_case			:      Optional[int]        =			vocab_size
          snake_case			:      int        =			d_model
          snake_case			:      Optional[int]        =			d_kv
          snake_case			:      int        =			d_ff
          snake_case			:      Tuple        =			num_layers
          snake_case			:      Union[str, Any]        =			(
              num_decoder_layers if num_decoder_layers is not None else self.num_layers
          )  # default = symmetry
          snake_case			:      List[str]        =			num_heads
          snake_case			:      str        =			relative_attention_num_buckets
          snake_case			:      str        =			relative_attention_max_distance
          snake_case			:      Dict        =			dropout_rate
          snake_case			:      Optional[int]        =			layer_norm_epsilon
          snake_case			:      Union[str, Any]        =			initializer_factor
          snake_case			:      List[Any]        =			feed_forward_proj
          snake_case			:      int        =			use_cache

          snake_case			:      List[Any]        =			self.feed_forward_proj.split("""-"""							)
          snake_case			:      str        =			act_info[-1]
          snake_case			:      int        =			act_info[0] == """gated"""

          if len(__a							) > 1 and act_info[0] != "gated" or len(__a							) > 2:
               raise ValueError(
                   F'''`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer.'''
                   """Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. """
                   """'gated-gelu' or 'relu'"""							)

          if feed_forward_proj == "gated-gelu":
               snake_case			:      Any        =			"""gelu_new"""







     @property
     def 			snake_case_      (				self							)      ->				Union[str, Any]:
          return self.d_model







     @property
     def 			snake_case_      (				self							)      ->				List[Any]:
          return self.num_heads







     @property
     def 			snake_case_      (				self							)      ->				Union[str, Any]:
          return self.num_layers







class 					_a (a__	):





     '''simple docstring'''



     @property
     # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
     def 			snake_case_      (				self							)      ->				Mapping[str, Mapping[int, str]]:
          snake_case			:      str        =			{
              """input_ids""": {0: """batch""", 1: """encoder_sequence"""},
              """attention_mask""": {0: """batch""", 1: """encoder_sequence"""},
          }
          if self.use_past:
               snake_case			:      Dict        =			"""past_encoder_sequence + sequence"""
               snake_case			:      Tuple        =			{0: """batch"""}
               snake_case			:      Dict        =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
          else:
               snake_case			:      Any        =			{0: """batch""", 1: """decoder_sequence"""}
               snake_case			:      str        =			{0: """batch""", 1: """decoder_sequence"""}

          if self.use_past:
               self.fill_with_past_key_values_(__a							,direction="""inputs"""							)

          return common_inputs







     @property
     # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
     def 			snake_case_      (				self							)      ->				int:
          return 13







     @property
     def 			snake_case_      (				self							)      ->				float:
          return 5E-4









'''simple docstring'''







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


lowercase      :   Tuple      =       {"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

lowercase      :   Dict      =       {
    """vocab_file""": {
        """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt""",
    },
    """tokenizer_file""": {
        """unc-nlp/lxmert-base-uncased""": (
            """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"""
        ),
    },
}

lowercase      :   List[Any]      =       {
    """unc-nlp/lxmert-base-uncased""": 512,
}

lowercase      :   Tuple      =       {
    """unc-nlp/lxmert-base-uncased""": {"""do_lower_case""": True},
}







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Optional[int]          =					VOCAB_FILES_NAMES
     lowerCAmelCase_  :     Optional[int]          =					PRETRAINED_VOCAB_FILES_MAP
     lowerCAmelCase_  :     Any          =					PRETRAINED_INIT_CONFIGURATION
     lowerCAmelCase_  :     Optional[int]          =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     lowerCAmelCase_  :     Optional[int]          =					LxmertTokenizer







     def __init__(				self							,__a=None							,__a=None							,__a=True							,__a="[UNK]"							,__a="[SEP]"							,__a="[PAD]"							,__a="[CLS]"							,__a="[MASK]"							,__a=True							,__a=None							,**__a							,)      ->				str:
          super().__init__(
              __a							,tokenizer_file=__a							,do_lower_case=__a							,unk_token=__a							,sep_token=__a							,pad_token=__a							,cls_token=__a							,mask_token=__a							,tokenize_chinese_chars=__a							,strip_accents=__a							,**__a							,)

          snake_case			:      List[Any]        =			json.loads(self.backend_tokenizer.normalizer.__getstate__()							)
          if (
              normalizer_state.get("""lowercase"""							,__a							) != do_lower_case
              or normalizer_state.get("""strip_accents"""							,__a							) != strip_accents
              or normalizer_state.get("""handle_chinese_chars"""							,__a							) != tokenize_chinese_chars
          ):
               snake_case			:      Union[str, Any]        =			getattr(__a							,normalizer_state.pop("""type"""							)							)
               snake_case			:      Optional[int]        =			do_lower_case
               snake_case			:      Optional[int]        =			strip_accents
               snake_case			:      List[Any]        =			tokenize_chinese_chars
               snake_case			:      Union[str, Any]        =			normalizer_class(**__a							)

          snake_case			:      str        =			do_lower_case







     def 			snake_case_      (				self							,__a							,__a=None							)      ->				Optional[int]:
          snake_case			:      Tuple        =			[self.cls_token_id] + token_ids_a + [self.sep_token_id]

          if token_ids_a:
               output += token_ids_a + [self.sep_token_id]

          return output







     def 			snake_case_      (				self							,__a							,__a = None							)      ->				List[int]:
          snake_case			:      int        =			[self.sep_token_id]
          snake_case			:      Any        =			[self.cls_token_id]
          if token_ids_a is None:
               return len(cls + token_ids_a + sep							) * [0]
          return len(cls + token_ids_a + sep							) * [0] + len(token_ids_a + sep							) * [1]







     def 			snake_case_      (				self							,__a							,__a = None							)      ->				Tuple[str]:
          snake_case			:      Optional[int]        =			self._tokenizer.model.save(__a							,name=__a							)
          return tuple(__a							)



