




"""simple docstring"""






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






			'''simple docstring'''



			lowerCamelCase__ =     ["""image_processor""", """tokenizer"""]
			lowerCamelCase__ =     """FlavaImageProcessor"""
			lowerCamelCase__ =     ("""BertTokenizer""", """BertTokenizerFast""")
			def __init__(    self    , lowercase=None    , lowercase=None    , **lowercase    ):
							_lowerCamelCase	:     str       =       None
							if "feature_extractor" in kwargs:
											warnings.warn(
											    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
											    ' instead.'    , lowercase    , )
											_lowerCamelCase	:     List[Any]       =       kwargs.pop('feature_extractor'    )

							_lowerCamelCase	:     str       =       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__(lowercase    , lowercase    )
							_lowerCamelCase	:     Union[str, Any]       =       self.image_processor
			def __call__(    self    , lowercase = None    , lowercase = None    , lowercase = True    , lowercase = False    , lowercase = False    , lowercase = None    , lowercase = 0    , lowercase = None    , lowercase = None    , lowercase = None    , lowercase = None    , lowercase = None    , lowercase = False    , lowercase = False    , lowercase = False    , lowercase = False    , lowercase = True    , lowercase = None    , **lowercase    , ):

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

							if text is not None and images is not None:
											encoding.update(lowercase    )
											return encoding
							elif text is not None:
											return encoding
							else:
											return BatchEncoding(data=dict(**lowercase    )    , tensor_type=lowercase    )
			def    A_       (    self    , *lowercase    , **lowercase    ):
							return self.tokenizer.batch_decode(*lowercase    , **lowercase    )
			def    A_       (    self    , *lowercase    , **lowercase    ):
							return self.tokenizer.decode(*lowercase    , **lowercase    )
			@property
			def    A_       (    self    ):
							_lowerCamelCase	:     List[str]       =       self.tokenizer.model_input_names
							_lowerCamelCase	:     Optional[int]       =       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.'    , lowercase    , )
							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.'    , lowercase    , )
							return self.image_processor





"""simple docstring"""






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


lowercase__			=		logging.get_logger(__name__)

lowercase__			=		{"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""}






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     """openai-gpt"""
			lowerCamelCase__ =     {
			    """max_position_embeddings""": """n_positions""",
			    """hidden_size""": """n_embd""",
			    """num_attention_heads""": """n_head""",
			    """num_hidden_layers""": """n_layer""",
			}
			def __init__(    self    , lowercase=40478    , lowercase=512    , lowercase=768    , lowercase=12    , lowercase=12    , lowercase="gelu"    , lowercase=0.1    , lowercase=0.1    , lowercase=0.1    , lowercase=1E-5    , lowercase=0.02    , lowercase="cls_index"    , lowercase=True    , lowercase=None    , lowercase=True    , lowercase=0.1    , **lowercase    , ):
							_lowerCamelCase	:     Tuple       =       vocab_size
							_lowerCamelCase	:     List[str]       =       n_positions
							_lowerCamelCase	:     Tuple       =       n_embd
							_lowerCamelCase	:     Optional[int]       =       n_layer
							_lowerCamelCase	:     List[Any]       =       n_head
							_lowerCamelCase	:     Dict       =       afn
							_lowerCamelCase	:     Union[str, Any]       =       resid_pdrop
							_lowerCamelCase	:     Dict       =       embd_pdrop
							_lowerCamelCase	:     List[Any]       =       attn_pdrop
							_lowerCamelCase	:     Any       =       layer_norm_epsilon
							_lowerCamelCase	:     List[Any]       =       initializer_range
							_lowerCamelCase	:     List[Any]       =       summary_type
							_lowerCamelCase	:     List[str]       =       summary_use_proj
							_lowerCamelCase	:     Tuple       =       summary_activation
							_lowerCamelCase	:     int       =       summary_first_dropout
							_lowerCamelCase	:     str       =       summary_proj_to_labels
							super().__init__(**lowercase    )