


import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 	__lowercase    (__SCREAMING_SNAKE_CASE  ):





							"""simple docstring"""







							_UpperCAmelCase      =						["""image_processor""", """tokenizer"""]
							_UpperCAmelCase      =						"""ViTImageProcessor"""
							_UpperCAmelCase      =						("""CLIPTokenizer""", """CLIPTokenizerFast""")






							def __init__(      self			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						**lowerCAmelCase__       ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:     Any					=					None
										if "feature_extractor" in kwargs:
													warnings.warn(
													    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
													    ' instead.'			,						lowerCAmelCase__			,						)
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					kwargs.pop('feature_extractor'       )

										SCREAMING_SNAKE_CASE_		:     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__(lowerCAmelCase__			,						lowerCAmelCase__       )






							def __call__(      self			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						**lowerCAmelCase__       ):





										"""simple docstring"""




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

										if text is not None and visual_prompt is not None:
													raise ValueError('You have to specify exactly one type of prompt. Either text or visual prompt.'       )

										if text is not None:
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					self.tokenizer(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if visual_prompt is not None:
													SCREAMING_SNAKE_CASE_		:     int					=					self.image_processor(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if images is not None:
													SCREAMING_SNAKE_CASE_		:     Dict					=					self.image_processor(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if visual_prompt is not None and images is not None:
													SCREAMING_SNAKE_CASE_		:     List[str]					=					{
													    'pixel_values': image_features.pixel_values,
													    'conditional_pixel_values': prompt_features.pixel_values,
													}
													return encoding
										elif text is not None and images is not None:
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					image_features.pixel_values
													return encoding
										elif text is not None:
													return encoding
										elif visual_prompt is not None:
													SCREAMING_SNAKE_CASE_		:     Tuple					=					{
													    'conditional_pixel_values': prompt_features.pixel_values,
													}
													return encoding
										else:
													return BatchEncoding(data=dict(**lowerCAmelCase__       )			,						tensor_type=lowerCAmelCase__       )






							def 					UpperCamelCase__     (      self			,						*lowerCAmelCase__			,						**lowerCAmelCase__       ):





										"""simple docstring"""




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






							def 					UpperCamelCase__     (      self			,						*lowerCAmelCase__			,						**lowerCAmelCase__       ):





										"""simple docstring"""




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






							@property
							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




										warnings.warn(
										    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'			,						lowerCAmelCase__			,						)
										return self.image_processor_class






							@property
							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




										warnings.warn(
										    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'			,						lowerCAmelCase__			,						)
										return self.image_processor






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


a  :      List[Any]            =    logging.get_logger(__name__)

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

class 					_lowercase    (     UpperCAmelCase__			):






    '''simple docstring'''
    SCREAMING_SNAKE_CASE:				int          =    'openai-gpt'
    SCREAMING_SNAKE_CASE:				List[str]          =    {
        'max_position_embeddings': 'n_positions',
        'hidden_size': 'n_embd',
        'num_attention_heads': 'n_head',
        'num_hidden_layers': 'n_layer',
    }




    def __init__(    self       ,						lowerCamelCase__=40_478       ,						lowerCamelCase__=512       ,						lowerCamelCase__=768       ,						lowerCamelCase__=12       ,						lowerCamelCase__=12       ,						lowerCamelCase__="gelu"       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=1E-5       ,						lowerCamelCase__=0.0_2       ,						lowerCamelCase__="cls_index"       ,						lowerCamelCase__=True       ,						lowerCamelCase__=None       ,						lowerCamelCase__=True       ,						lowerCamelCase__=0.1       ,						**lowerCamelCase__       ,						):
       lowerCAmelCase_:							Union[str, Any]       =	vocab_size
       lowerCAmelCase_:							List[Any]       =	n_positions
       lowerCAmelCase_:							Tuple       =	n_embd
       lowerCAmelCase_:							Optional[int]       =	n_layer
       lowerCAmelCase_:							Optional[int]       =	n_head
       lowerCAmelCase_:							int       =	afn
       lowerCAmelCase_:							str       =	resid_pdrop
       lowerCAmelCase_:							Optional[int]       =	embd_pdrop
       lowerCAmelCase_:							Optional[int]       =	attn_pdrop
       lowerCAmelCase_:							Dict       =	layer_norm_epsilon
       lowerCAmelCase_:							List[Any]       =	initializer_range
       lowerCAmelCase_:							Union[str, Any]       =	summary_type
       lowerCAmelCase_:							Any       =	summary_use_proj
       lowerCAmelCase_:							Dict       =	summary_activation
       lowerCAmelCase_:							Dict       =	summary_first_dropout
       lowerCAmelCase_:							List[Any]       =	summary_proj_to_labels
       super().__init__(**lowerCamelCase__ )