



'''simple docstring'''


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  SCREAMING_SNAKE_CASE (  _a		):






    """simple docstring"""





    _SCREAMING_SNAKE_CASE	  =  ["""image_processor""", """tokenizer"""]
    _SCREAMING_SNAKE_CASE	  =  """BlipImageProcessor"""
    _SCREAMING_SNAKE_CASE	  =  ("""BertTokenizer""", """BertTokenizerFast""")






    def __init__(  self      :					Optional[int]  ,						UpperCamelCase__      :					Tuple  ,						UpperCamelCase__      :					Union[str, Any] ):


       """simple docstring"""







       UpperCamelCase					=  False
       super().__init__(UpperCamelCase__  ,						UpperCamelCase__ )
       UpperCamelCase					=  self.image_processor






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


       """simple docstring"""







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

       # Get only text
       if images is None:
          UpperCamelCase					=  self.tokenizer
          UpperCamelCase					=  self.tokenizer(
              text=UpperCamelCase__  ,						add_special_tokens=UpperCamelCase__  ,						padding=UpperCamelCase__  ,						truncation=UpperCamelCase__  ,						max_length=UpperCamelCase__  ,						stride=UpperCamelCase__  ,						pad_to_multiple_of=UpperCamelCase__  ,						return_attention_mask=UpperCamelCase__  ,						return_overflowing_tokens=UpperCamelCase__  ,						return_special_tokens_mask=UpperCamelCase__  ,						return_offsets_mapping=UpperCamelCase__  ,						return_token_type_ids=UpperCamelCase__  ,						return_length=UpperCamelCase__  ,						verbose=UpperCamelCase__  ,						return_tensors=UpperCamelCase__  ,						**UpperCamelCase__  ,						)
          return text_encoding

       # add pixel_values
       UpperCamelCase					=  self.image_processor(UpperCamelCase__  ,						return_tensors=UpperCamelCase__ )

       if text is not None:
          UpperCamelCase					=  self.tokenizer(
              text=UpperCamelCase__  ,						add_special_tokens=UpperCamelCase__  ,						padding=UpperCamelCase__  ,						truncation=UpperCamelCase__  ,						max_length=UpperCamelCase__  ,						stride=UpperCamelCase__  ,						pad_to_multiple_of=UpperCamelCase__  ,						return_attention_mask=UpperCamelCase__  ,						return_overflowing_tokens=UpperCamelCase__  ,						return_special_tokens_mask=UpperCamelCase__  ,						return_offsets_mapping=UpperCamelCase__  ,						return_token_type_ids=UpperCamelCase__  ,						return_length=UpperCamelCase__  ,						verbose=UpperCamelCase__  ,						return_tensors=UpperCamelCase__  ,						**UpperCamelCase__  ,						)
       else:
          UpperCamelCase					=  None

       if text_encoding is not None:
          encoding_image_processor.update(UpperCamelCase__ )

       return encoding_image_processor






    def  A       (  self      :					Tuple  ,						*UpperCamelCase__      :					Tuple  ,						**UpperCamelCase__      :					Any ):


       """simple docstring"""







       return self.tokenizer.batch_decode(*UpperCamelCase__  ,						**UpperCamelCase__ )






    def  A       (  self      :					Union[str, Any]  ,						*UpperCamelCase__      :					Tuple  ,						**UpperCamelCase__      :					Dict ):


       """simple docstring"""







       return self.tokenizer.decode(*UpperCamelCase__  ,						**UpperCamelCase__ )






    @property
    def  A       (  self      :					str ):


       """simple docstring"""







       UpperCamelCase					=  self.tokenizer.model_input_names
       UpperCamelCase					=  self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names ) )









from collections import OrderedDict
from typing import Mapping

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


_a      	=  logging.get_logger(__name__)

_a      	=  {
    '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-base-uncased/resolve/main/config.json''',
    '''distilbert-base-uncased-distilled-squad''': (
        '''https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/config.json'''
    ),
    '''distilbert-base-cased''': '''https://huggingface.co/distilbert-base-cased/resolve/main/config.json''',
    '''distilbert-base-cased-distilled-squad''': (
        '''https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/config.json'''
    ),
    '''distilbert-base-german-cased''': '''https://huggingface.co/distilbert-base-german-cased/resolve/main/config.json''',
    '''distilbert-base-multilingual-cased''': (
        '''https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/config.json'''
    ),
    '''distilbert-base-uncased-finetuned-sst-2-english''': (
        '''https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json'''
    ),
}





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	UpperCamelCase__								=      "distilbert"
	UpperCamelCase__								=      {
	    "hidden_size": "dim",
	    "num_attention_heads": "n_heads",
	    "num_hidden_layers": "n_layers",
	}

	def __init__(							self       ,    UpperCAmelCase=3_0522       ,    UpperCAmelCase=512       ,    UpperCAmelCase=False       ,    UpperCAmelCase=6       ,    UpperCAmelCase=12       ,    UpperCAmelCase=768       ,    UpperCAmelCase=4 * 768       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase="gelu"       ,    UpperCAmelCase=0.02       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.2       ,    UpperCAmelCase=0       ,    **UpperCAmelCase       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			vocab_size
							_UpperCAmelCase									=			max_position_embeddings
							_UpperCAmelCase									=			sinusoidal_pos_embds
							_UpperCAmelCase									=			n_layers
							_UpperCAmelCase									=			n_heads
							_UpperCAmelCase									=			dim
							_UpperCAmelCase									=			hidden_dim
							_UpperCAmelCase									=			dropout
							_UpperCAmelCase									=			attention_dropout
							_UpperCAmelCase									=			activation
							_UpperCAmelCase									=			initializer_range
							_UpperCAmelCase									=			qa_dropout
							_UpperCAmelCase									=			seq_classif_dropout
							super().__init__(**UpperCAmelCase       ,    pad_token_id=UpperCAmelCase    )





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							if self.task == "multiple-choice":
													_UpperCAmelCase									=			{0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
													_UpperCAmelCase									=			{0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]    )
