

from typing import List, Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_herbert import HerbertTokenizer


lowerCAmelCase__       = logging.get_logger(__name__)

lowerCAmelCase__       = {"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokenizer_file": "tokenizer.json"}

lowerCAmelCase__       = {
    "vocab_file": {
        "allegro/herbert-base-cased": "https://huggingface.co/allegro/herbert-base-cased/resolve/main/vocab.json"
    },
    "merges_file": {
        "allegro/herbert-base-cased": "https://huggingface.co/allegro/herbert-base-cased/resolve/main/merges.txt"
    },
}

lowerCAmelCase__       = {"allegro/herbert-base-cased": 514}
lowerCAmelCase__       = {}






class 						__magic_name__    (       _snake_case    ):
 UpperCAmelCase							    =						VOCAB_FILES_NAMES
 UpperCAmelCase							    =						PRETRAINED_VOCAB_FILES_MAP
 UpperCAmelCase							    =						PRETRAINED_INIT_CONFIGURATION
 UpperCAmelCase							    =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 UpperCAmelCase							    =						HerbertTokenizer


 def __init__(						self		: str			,						lowerCAmelCase__		: List[str]=None			,						lowerCAmelCase__		: Tuple=None			,						lowerCAmelCase__		: Any=None			,						lowerCAmelCase__		: Optional[int]="<s>"			,						lowerCAmelCase__		: int="<unk>"			,						lowerCAmelCase__		: List[str]="<pad>"			,						lowerCAmelCase__		: int="<mask>"			,						lowerCAmelCase__		: Any="</s>"			,						**lowerCAmelCase__		: Any			,						)    ->      Union[str, Any]:
   super().__init__(
       lowerCAmelCase__			,						lowerCAmelCase__			,						tokenizer_file=lowerCAmelCase__			,						cls_token=lowerCAmelCase__			,						unk_token=lowerCAmelCase__			,						pad_token=lowerCAmelCase__			,						mask_token=lowerCAmelCase__			,						sep_token=lowerCAmelCase__			,						**lowerCAmelCase__			,						)


 def _UpperCamelCase	(						self		: Union[str, Any]			,						lowerCAmelCase__		: List[int]			,						lowerCAmelCase__		: Optional[List[int]] = None    )    ->      List[int]:
   UpperCAmelCase					      =  [self.cls_token_id]
   UpperCAmelCase					      =  [self.sep_token_id]
   if token_ids_a is None:
     return cls + token_ids_a + sep

   return cls + token_ids_a + sep + token_ids_a + sep


 def _UpperCamelCase	(						self		: List[str]			,						lowerCAmelCase__		: List[int]			,						lowerCAmelCase__		: Optional[List[int]] = None			,						lowerCAmelCase__		: bool = False    )    ->      List[int]:
   if already_has_special_tokens:
     return super().get_special_tokens_mask(
         token_ids_a=lowerCAmelCase__			,						token_ids_a=lowerCAmelCase__			,						already_has_special_tokens=lowerCAmelCase__    )

   if token_ids_a is None:
     return [1] + ([0] * len(lowerCAmelCase__    )) + [1]
   return [1] + ([0] * len(lowerCAmelCase__    )) + [1] + ([0] * len(lowerCAmelCase__    )) + [1]


 def _UpperCamelCase	(						self		: Union[str, Any]			,						lowerCAmelCase__		: List[int]			,						lowerCAmelCase__		: Optional[List[int]] = None    )    ->      List[int]:
   UpperCAmelCase					      =  [self.sep_token_id]
   UpperCAmelCase					      =  [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 _UpperCamelCase	(						self		: Tuple			,						lowerCAmelCase__		: str			,						lowerCAmelCase__		: Optional[str] = None    )    ->      Tuple[str]:
   UpperCAmelCase					      =  self._tokenizer.model.save(lowerCAmelCase__			,						name=lowerCAmelCase__    )
   return tuple(lowerCAmelCase__    )






from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__       = logging.get_logger(__name__)

lowerCAmelCase__       = {
    "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json",
}






class 						__magic_name__    (       _snake_case    ):
 UpperCAmelCase							    =						"""lxmert"""
 UpperCAmelCase							    =						{}


 def __init__(						self		: int			,						lowerCAmelCase__		: Any=3_0_5_2_2			,						lowerCAmelCase__		: List[str]=7_6_8			,						lowerCAmelCase__		: Union[str, Any]=1_2			,						lowerCAmelCase__		: List[Any]=9_5_0_0			,						lowerCAmelCase__		: Any=1_6_0_0			,						lowerCAmelCase__		: Union[str, Any]=4_0_0			,						lowerCAmelCase__		: Tuple=3_0_7_2			,						lowerCAmelCase__		: Dict="gelu"			,						lowerCAmelCase__		: Tuple=0.1			,						lowerCAmelCase__		: Tuple=0.1			,						lowerCAmelCase__		: int=5_1_2			,						lowerCAmelCase__		: List[str]=2			,						lowerCAmelCase__		: List[str]=0.02			,						lowerCAmelCase__		: str=1e-1_2			,						lowerCAmelCase__		: str=9			,						lowerCAmelCase__		: int=5			,						lowerCAmelCase__		: Optional[int]=5			,						lowerCAmelCase__		: List[Any]=2_0_4_8			,						lowerCAmelCase__		: Any=4			,						lowerCAmelCase__		: Dict=6.67			,						lowerCAmelCase__		: Any=True			,						lowerCAmelCase__		: Union[str, Any]=True			,						lowerCAmelCase__		: Any=True			,						lowerCAmelCase__		: Tuple=True			,						lowerCAmelCase__		: Optional[Any]=True			,						lowerCAmelCase__		: Optional[int]=True			,						lowerCAmelCase__		: Tuple=True			,						**lowerCAmelCase__		: List[Any]			,						)    ->      Dict:
   UpperCAmelCase					      =  vocab_size
   UpperCAmelCase					      =  hidden_size
   UpperCAmelCase					      =  num_attention_heads
   UpperCAmelCase					      =  hidden_act
   UpperCAmelCase					      =  intermediate_size
   UpperCAmelCase					      =  hidden_dropout_prob
   UpperCAmelCase					      =  attention_probs_dropout_prob
   UpperCAmelCase					      =  max_position_embeddings
   UpperCAmelCase					      =  type_vocab_size
   UpperCAmelCase					      =  initializer_range
   UpperCAmelCase					      =  layer_norm_eps
   UpperCAmelCase					      =  num_qa_labels
   UpperCAmelCase					      =  num_object_labels
   UpperCAmelCase					      =  num_attr_labels
   UpperCAmelCase					      =  l_layers
   UpperCAmelCase					      =  x_layers
   UpperCAmelCase					      =  r_layers
   UpperCAmelCase					      =  visual_feat_dim
   UpperCAmelCase					      =  visual_pos_dim
   UpperCAmelCase					      =  visual_loss_normalizer
   UpperCAmelCase					      =  task_matched
   UpperCAmelCase					      =  task_mask_lm
   UpperCAmelCase					      =  task_obj_predict
   UpperCAmelCase					      =  task_qa
   UpperCAmelCase					      =  visual_obj_loss
   UpperCAmelCase					      =  visual_attr_loss
   UpperCAmelCase					      =  visual_feat_loss
   UpperCAmelCase					      =  {"vision": r_layers, "cross_encoder": x_layers, "language": l_layers}
   super().__init__(**lowerCAmelCase__    )



