





import warnings
from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType





class 				A_				(      UpperCAmelCase	):







       """simple docstring"""





       SCREAMING_SNAKE_CASE_      : List[str]      =  ['''image_processor''', '''tokenizer''']
       SCREAMING_SNAKE_CASE_      : int      =  '''FlavaImageProcessor'''
       SCREAMING_SNAKE_CASE_      : Union[str, Any]      =  ('''BertTokenizer''', '''BertTokenizerFast''')







       def __init__(    self	:	int						,__A	:	Any=None						,__A	:	Union[str, Any]=None						,**__A	:	Any  )						->					int:
        _lowercase							= 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						,)
         _lowercase							= kwargs.pop('feature_extractor'  )

        _lowercase							= 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  )
        _lowercase							= self.image_processor







       def __call__(    self	:	Union[str, Any]						,__A	:	Optional[ImageInput] = None						,__A	:	Optional[Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]] = None						,__A	:	bool = True						,__A	:	Union[bool, str, PaddingStrategy] = False						,__A	:	Union[bool, str, TruncationStrategy] = False						,__A	:	Optional[int] = None						,__A	:	int = 0						,__A	:	Optional[int] = None						,__A	:	Optional[bool] = None						,__A	:	Optional[bool] = None						,__A	:	Optional[bool] = None						,__A	:	Optional[bool] = None						,__A	:	bool = False						,__A	:	bool = False						,__A	:	bool = False						,__A	:	bool = False						,__A	:	bool = True						,__A	:	Optional[Union[str, TensorType]] = None						,**__A	:	List[Any]						,)						->					str:

        if text is None and images is None:
         raise ValueError('You have to specify either text or images. Both cannot be none.'  )

        if text is not None:
         _lowercase							= 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						,)
        if images is not None:
         _lowercase							= self.image_processor(
             __A						,return_image_mask=__A						,return_codebook_pixels=__A						,return_tensors=__A						,**__A						,)

        if text is not None and images is not None:
         encoding.update(__A  )
         return encoding
        elif text is not None:
         return encoding
        else:
         return BatchEncoding(data=dict(**__A  )						,tensor_type=__A  )







       def    __UpperCAmelCase (    self	:	Any						,*__A	:	Optional[int]						,**__A	:	Tuple  )						->					Any:
        return self.tokenizer.batch_decode(*__A						,**__A  )







       def    __UpperCAmelCase (    self	:	Any						,*__A	:	str						,**__A	:	Any  )						->					Union[str, Any]:
        return self.tokenizer.decode(*__A						,**__A  )







       @property
       def    __UpperCAmelCase (    self	:	Union[str, Any]  )						->					List[str]:
        _lowercase							= self.tokenizer.model_input_names
        _lowercase							= self.image_processor.model_input_names
        return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names  )  )







       @property
       def    __UpperCAmelCase (    self	:	Tuple  )						->					Optional[Any]:
        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    __UpperCAmelCase (    self	:	Optional[int]  )						->					int:
        warnings.warn(
            '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'						,__A						,)
        return self.image_processor






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tensorflow_text_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case 				=       {
    """configuration_bert""": ["""BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BertConfig""", """BertOnnxConfig"""],
    """tokenization_bert""": ["""BasicTokenizer""", """BertTokenizer""", """WordpieceTokenizer"""],
}

try:
      if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      snake_case 				=       ["""BertTokenizerFast"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      snake_case 				=       [
          """BERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """BertForMaskedLM""",
          """BertForMultipleChoice""",
          """BertForNextSentencePrediction""",
          """BertForPreTraining""",
          """BertForQuestionAnswering""",
          """BertForSequenceClassification""",
          """BertForTokenClassification""",
          """BertLayer""",
          """BertLMHeadModel""",
          """BertModel""",
          """BertPreTrainedModel""",
          """load_tf_weights_in_bert""",
      ]

try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      snake_case 				=       [
          """TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """TFBertEmbeddings""",
          """TFBertForMaskedLM""",
          """TFBertForMultipleChoice""",
          """TFBertForNextSentencePrediction""",
          """TFBertForPreTraining""",
          """TFBertForQuestionAnswering""",
          """TFBertForSequenceClassification""",
          """TFBertForTokenClassification""",
          """TFBertLMHeadModel""",
          """TFBertMainLayer""",
          """TFBertModel""",
          """TFBertPreTrainedModel""",
      ]
try:
      if not is_tensorflow_text_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      snake_case 				=       ["""TFBertTokenizer"""]

try:
      if not is_flax_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      snake_case 				=       [
          """FlaxBertForCausalLM""",
          """FlaxBertForMaskedLM""",
          """FlaxBertForMultipleChoice""",
          """FlaxBertForNextSentencePrediction""",
          """FlaxBertForPreTraining""",
          """FlaxBertForQuestionAnswering""",
          """FlaxBertForSequenceClassification""",
          """FlaxBertForTokenClassification""",
          """FlaxBertModel""",
          """FlaxBertPreTrainedModel""",
      ]

if TYPE_CHECKING:
      from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig, BertOnnxConfig
      from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer

      try:
            if not is_tokenizers_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_bert_fast import BertTokenizerFast

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_bert import (
                BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                BertForMaskedLM,
                BertForMultipleChoice,
                BertForNextSentencePrediction,
                BertForPreTraining,
                BertForQuestionAnswering,
                BertForSequenceClassification,
                BertForTokenClassification,
                BertLayer,
                BertLMHeadModel,
                BertModel,
                BertPreTrainedModel,
                load_tf_weights_in_bert,
            )

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_bert import (
                TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                TFBertEmbeddings,
                TFBertForMaskedLM,
                TFBertForMultipleChoice,
                TFBertForNextSentencePrediction,
                TFBertForPreTraining,
                TFBertForQuestionAnswering,
                TFBertForSequenceClassification,
                TFBertForTokenClassification,
                TFBertLMHeadModel,
                TFBertMainLayer,
                TFBertModel,
                TFBertPreTrainedModel,
            )

      try:
            if not is_tensorflow_text_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_bert_tf import TFBertTokenizer

      try:
            if not is_flax_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_flax_bert import (
                FlaxBertForCausalLM,
                FlaxBertForMaskedLM,
                FlaxBertForMultipleChoice,
                FlaxBertForNextSentencePrediction,
                FlaxBertForPreTraining,
                FlaxBertForQuestionAnswering,
                FlaxBertForSequenceClassification,
                FlaxBertForTokenClassification,
                FlaxBertModel,
                FlaxBertPreTrainedModel,
            )

else:
      import sys

      snake_case 				=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)