

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 	lowercase    (				_lowercase							):


		"""simple docstring"""




		a__					       =  ["image_processor", "tokenizer"]
		a__					       =  "FlavaImageProcessor"
		a__					       =  ("BertTokenizer", "BertTokenizerFast")


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

			_UpperCamelCase   :		Optional[Any]			=						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__(__snake_case	,       __snake_case)
			_UpperCamelCase   :		List[str]			=						self.image_processor


		def __call__(				self	,       __snake_case = None	,       __snake_case = None	,       __snake_case = True	,       __snake_case = False	,       __snake_case = False	,       __snake_case = None	,       __snake_case = 0	,       __snake_case = None	,       __snake_case = None	,       __snake_case = None	,       __snake_case = None	,       __snake_case = None	,       __snake_case = False	,       __snake_case = False	,       __snake_case = False	,       __snake_case = False	,       __snake_case = True	,       __snake_case = None	,       **__snake_case	,       ):

			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:
				_UpperCamelCase   :		Optional[int]			=						self.tokenizer(
				    text=__snake_case	,       add_special_tokens=__snake_case	,       padding=__snake_case	,       truncation=__snake_case	,       max_length=__snake_case	,       stride=__snake_case	,       pad_to_multiple_of=__snake_case	,       return_token_type_ids=__snake_case	,       return_attention_mask=__snake_case	,       return_overflowing_tokens=__snake_case	,       return_special_tokens_mask=__snake_case	,       return_offsets_mapping=__snake_case	,       return_length=__snake_case	,       verbose=__snake_case	,       return_tensors=__snake_case	,       **__snake_case	,       )
			if images is not None:
				_UpperCamelCase   :		Any			=						self.image_processor(
				    __snake_case	,       return_image_mask=__snake_case	,       return_codebook_pixels=__snake_case	,       return_tensors=__snake_case	,       **__snake_case	,       )

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


		def 		A__					(				self	,       *__snake_case	,       **__snake_case):
			return self.tokenizer.batch_decode(*__snake_case	,       **__snake_case)


		def 		A__					(				self	,       *__snake_case	,       **__snake_case):
			return self.tokenizer.decode(*__snake_case	,       **__snake_case)


		@property
		def 		A__					(				self):
			_UpperCamelCase   :		Optional[Any]			=						self.tokenizer.model_input_names
			_UpperCamelCase   :		List[str]			=						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.'	,       __snake_case	,       )
			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.'	,       __snake_case	,       )
			return self.image_processor







from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase__								=		logging.get_logger(__name__)

lowerCAmelCase__								=		{
    """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
    """bert-large-uncased""": """https://huggingface.co/bert-large-uncased/resolve/main/config.json""",
    """bert-base-cased""": """https://huggingface.co/bert-base-cased/resolve/main/config.json""",
    """bert-large-cased""": """https://huggingface.co/bert-large-cased/resolve/main/config.json""",
    """bert-base-multilingual-uncased""": """https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json""",
    """bert-base-multilingual-cased""": """https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json""",
    """bert-base-chinese""": """https://huggingface.co/bert-base-chinese/resolve/main/config.json""",
    """bert-base-german-cased""": """https://huggingface.co/bert-base-german-cased/resolve/main/config.json""",
    """bert-large-uncased-whole-word-masking""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-uncased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-base-cased-finetuned-mrpc""": """https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json""",
    """bert-base-german-dbmdz-cased""": """https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json""",
    """bert-base-german-dbmdz-uncased""": """https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese""": """https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-cased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-uncased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json"""
    ),
    """wietsedv/bert-base-dutch-cased""": """https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json""",
    # See all BERT models at https://huggingface.co/models?filter=bert
}







class 	lowercase    (				_lowercase							):


		"""simple docstring"""




		a__					       =  "bert"


		def __init__(				self	,       __snake_case=3_05_22	,       __snake_case=7_68	,       __snake_case=12	,       __snake_case=12	,       __snake_case=30_72	,       __snake_case="gelu"	,       __snake_case=0.1	,       __snake_case=0.1	,       __snake_case=5_12	,       __snake_case=2	,       __snake_case=0.0_2	,       __snake_case=1e-12	,       __snake_case=0	,       __snake_case="absolute"	,       __snake_case=True	,       __snake_case=None	,       **__snake_case	,       ):
			super().__init__(pad_token_id=__snake_case	,       **__snake_case)

			_UpperCamelCase   :		int			=						vocab_size
			_UpperCamelCase   :		Optional[Any]			=						hidden_size
			_UpperCamelCase   :		Optional[Any]			=						num_hidden_layers
			_UpperCamelCase   :		List[str]			=						num_attention_heads
			_UpperCamelCase   :		int			=						hidden_act
			_UpperCamelCase   :		Optional[Any]			=						intermediate_size
			_UpperCamelCase   :		Union[str, Any]			=						hidden_dropout_prob
			_UpperCamelCase   :		Tuple			=						attention_probs_dropout_prob
			_UpperCamelCase   :		Optional[int]			=						max_position_embeddings
			_UpperCamelCase   :		str			=						type_vocab_size
			_UpperCamelCase   :		Optional[Any]			=						initializer_range
			_UpperCamelCase   :		List[str]			=						layer_norm_eps
			_UpperCamelCase   :		Any			=						position_embedding_type
			_UpperCamelCase   :		Any			=						use_cache
			_UpperCamelCase   :		Any			=						classifier_dropout







class 	lowercase    (				_lowercase							):


		"""simple docstring"""




		@property
		def 		A__					(				self):
			if self.task == "multiple-choice":
				_UpperCamelCase   :		Union[str, Any]			=						{0: 'batch', 1: 'choice', 2: 'sequence'}
			else:
				_UpperCamelCase   :		Optional[Any]			=						{0: 'batch', 1: 'sequence'}
			return OrderedDict(
			    [
			        ('input_ids', dynamic_axis),
			        ('attention_mask', dynamic_axis),
			        ('token_type_ids', dynamic_axis),
			    ])




