


'''simple docstring'''







import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
class 					lowercase_     (    a__   ):
    __UpperCAmelCase   			=	['image_processor', 'tokenizer']
    __UpperCAmelCase   			=	'ViltImageProcessor'
    __UpperCAmelCase   			=	('BertTokenizer', 'BertTokenizerFast')


    def __init__(     self  ,					a=None  ,					a=None  ,					**a    ):
          UpperCamelCase__										=				None
          if "feature_extractor" in kwargs:
                warnings.warn(
                    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                    " instead."  ,					a  ,					)
                UpperCamelCase__										=				kwargs.pop("feature_extractor"    )

          UpperCamelCase__										=				image_processor if image_processor is not None else feature_extractor
          if image_processor is None:
                raise ValueError("You need to specify an `image_processor`."    )
          if tokenizer is None:
                raise ValueError("You need to specify a `tokenizer`."    )

          super().__init__(a  ,					a    )
          UpperCamelCase__										=				self.image_processor


    def __call__(     self  ,					a  ,					a = None  ,					a = True  ,					a = False  ,					a = None  ,					a = None  ,					a = 0  ,					a = None  ,					a = None  ,					a = None  ,					a = False  ,					a = False  ,					a = False  ,					a = False  ,					a = True  ,					a = None  ,					**a  ,					):
          UpperCamelCase__										=				self.tokenizer(
              text=a  ,					add_special_tokens=a  ,					padding=a  ,					truncation=a  ,					max_length=a  ,					stride=a  ,					pad_to_multiple_of=a  ,					return_token_type_ids=a  ,					return_attention_mask=a  ,					return_overflowing_tokens=a  ,					return_special_tokens_mask=a  ,					return_offsets_mapping=a  ,					return_length=a  ,					verbose=a  ,					return_tensors=a  ,					**a  ,					)
          # add pixel_values + pixel_mask
          UpperCamelCase__										=				self.image_processor(a  ,					return_tensors=a    )
          encoding.update(a    )

          return encoding


    def    __a							(     self  ,					*a  ,					**a    ):
          return self.tokenizer.batch_decode(*a  ,					**a    )


    def    __a							(     self  ,					*a  ,					**a    ):
          return self.tokenizer.decode(*a  ,					**a    )


    @property
    def    __a							(     self    ):
          UpperCamelCase__										=				self.tokenizer.model_input_names
          UpperCamelCase__										=				self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names    )    )


    @property
    def    __a							(     self    ):
          warnings.warn(
              "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."  ,					a  ,					)
          return self.image_processor_class


    @property
    def    __a							(     self    ):
          warnings.warn(
              "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."  ,					a  ,					)
          return self.image_processor







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

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


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

__lowerCamelCase							=       {
    """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"""
        ),
    },
}

__lowerCamelCase							=       {
    """unc-nlp/lxmert-base-uncased""": 5_12,
}

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






class   UpperCAmelCase		(						A_ ):
   A__					:		Any						     =     VOCAB_FILES_NAMES
   A__					:		Optional[int]						     =     PRETRAINED_VOCAB_FILES_MAP
   A__					:		Tuple						     =     PRETRAINED_INIT_CONFIGURATION
   A__					:		Tuple						     =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   A__					:		List[Any]						     =     LxmertTokenizer



   def __init__(self		:					Dict    ,						snake_case__		:					Tuple=None    ,						snake_case__		:					Optional[Any]=None    ,						snake_case__		:					Optional[Any]=True    ,						snake_case__		:					Tuple="[UNK]"    ,						snake_case__		:					Optional[Any]="[SEP]"    ,						snake_case__		:					Optional[Any]="[PAD]"    ,						snake_case__		:					List[Any]="[CLS]"    ,						snake_case__		:					Tuple="[MASK]"    ,						snake_case__		:					Dict=True    ,						snake_case__		:					Union[str, Any]=None    ,						**snake_case__		:					Dict    ,						)		->	Optional[int]:


          '''simple docstring'''


          super().__init__(
              snake_case__    ,						tokenizer_file=snake_case__    ,						do_lower_case=snake_case__    ,						unk_token=snake_case__    ,						sep_token=snake_case__    ,						pad_token=snake_case__    ,						cls_token=snake_case__    ,						mask_token=snake_case__    ,						tokenize_chinese_chars=snake_case__    ,						strip_accents=snake_case__    ,						**snake_case__    ,						)

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

          snake_case       :   Optional[Any]							=      do_lower_case



   def 				_SCREAMING_SNAKE_CASE   (self		:					Union[str, Any]    ,						snake_case__		:					Optional[Any]    ,						snake_case__		:					Dict=None )		->	Any:


          '''simple docstring'''


          snake_case       :   Optional[int]							=      [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 				_SCREAMING_SNAKE_CASE   (self		:					Optional[int]    ,						snake_case__		:					List[int]    ,						snake_case__		:					Optional[List[int]] = None )		->	List[int]:


          '''simple docstring'''


          snake_case       :   Optional[Any]							=      [self.sep_token_id]
          snake_case       :   Optional[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 				_SCREAMING_SNAKE_CASE   (self		:					Any    ,						snake_case__		:					str    ,						snake_case__		:					Optional[str] = None )		->	Tuple[str]:


          '''simple docstring'''


          snake_case       :   List[Any]							=      self._tokenizer.model.save(snake_case__    ,						name=snake_case__ )
          return tuple(snake_case__ )





