

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


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

__A     :					Tuple     = {
    'transfo-xl-wt103': 'https://huggingface.co/transfo-xl-wt103/resolve/main/config.json',
}


class        _SCREAMING_SNAKE_CASE	(   lowercase__):
						_UpperCamelCase:List[Any]     =						'''transfo-xl'''
						_UpperCamelCase:List[Any]     =						['''mems''']
						_UpperCamelCase:Tuple     =						{
						    '''n_token''': '''vocab_size''',
						    '''hidden_size''': '''d_model''',
						    '''num_attention_heads''': '''n_head''',
						    '''num_hidden_layers''': '''n_layer''',
						}







						def __init__(       self			,		_SCREAMING_SNAKE_CASE=26_7735			,		_SCREAMING_SNAKE_CASE=[2_0000, 4_0000, 20_0000]			,		_SCREAMING_SNAKE_CASE=1024			,		_SCREAMING_SNAKE_CASE=1024			,		_SCREAMING_SNAKE_CASE=16			,		_SCREAMING_SNAKE_CASE=64			,		_SCREAMING_SNAKE_CASE=4096			,		_SCREAMING_SNAKE_CASE=4			,		_SCREAMING_SNAKE_CASE=False			,		_SCREAMING_SNAKE_CASE=18			,		_SCREAMING_SNAKE_CASE=1600			,		_SCREAMING_SNAKE_CASE=1000			,		_SCREAMING_SNAKE_CASE=True			,		_SCREAMING_SNAKE_CASE=True			,		_SCREAMING_SNAKE_CASE=0			,		_SCREAMING_SNAKE_CASE=-1			,		_SCREAMING_SNAKE_CASE=True			,		_SCREAMING_SNAKE_CASE=0.1			,		_SCREAMING_SNAKE_CASE=0.0			,		_SCREAMING_SNAKE_CASE=True			,		_SCREAMING_SNAKE_CASE="normal"			,		_SCREAMING_SNAKE_CASE=0.0_1			,		_SCREAMING_SNAKE_CASE=0.0_1			,		_SCREAMING_SNAKE_CASE=0.0_2			,		_SCREAMING_SNAKE_CASE=1E-5			,		_SCREAMING_SNAKE_CASE=0			,		**_SCREAMING_SNAKE_CASE			,		)->				Any:
													lowerCamelCase_				     =vocab_size
													lowerCamelCase_				     =[]
													self.cutoffs.extend(SCREAMING_SNAKE_CASE__				)
													if proj_share_all_but_first:
																				lowerCamelCase_				     =[False] + [True] * len(self.cutoffs				)
													else:
																				lowerCamelCase_				     =[False] + [False] * len(self.cutoffs				)
													lowerCamelCase_				     =d_model
													lowerCamelCase_				     =d_embed
													lowerCamelCase_				     =d_head
													lowerCamelCase_				     =d_inner
													lowerCamelCase_				     =div_val
													lowerCamelCase_				     =pre_lnorm
													lowerCamelCase_				     =n_layer
													lowerCamelCase_				     =n_head
													lowerCamelCase_				     =mem_len
													lowerCamelCase_				     =same_length
													lowerCamelCase_				     =attn_type
													lowerCamelCase_				     =clamp_len
													lowerCamelCase_				     =sample_softmax
													lowerCamelCase_				     =adaptive
													lowerCamelCase_				     =dropout
													lowerCamelCase_				     =dropatt
													lowerCamelCase_				     =untie_r
													lowerCamelCase_				     =init
													lowerCamelCase_				     =init_range
													lowerCamelCase_				     =proj_init_std
													lowerCamelCase_				     =init_std
													lowerCamelCase_				     =layer_norm_epsilon
													super().__init__(eos_token_id=SCREAMING_SNAKE_CASE__			,		**SCREAMING_SNAKE_CASE__				)







						@property
						def     _snake_case							(       self				)->				Dict:
													# Message copied from Transformer-XL documentation
													logger.info(f'The model {self.model_type} is one of the few models that has no sequence length limit.'				)
													return -1







						@max_position_embeddings.setter
						def     _snake_case							(       self			,		_SCREAMING_SNAKE_CASE				)->				List[Any]:
													# Message copied from Transformer-XL documentation
													raise NotImplementedError(
													    f'The model {self.model_type} is one of the few models that has no sequence length limit.'				)




import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class  SCREAMING_SNAKE_CASE__  (				lowercase__			):
      snake_case__				:     Tuple        =						['''image_processor''', '''tokenizer''']
      snake_case__				:     Union[str, Any]        =						'''CLIPImageProcessor'''
      snake_case__				:     Dict        =						('''CLIPTokenizer''', '''CLIPTokenizerFast''')
      def __init__(       self				:       Optional[int]     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=None     ,							SCREAMING_SNAKE_CASE__				:       List[str]=None     ,							**SCREAMING_SNAKE_CASE__				:       int     )		->			Any:
             a_					:		List[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.'     ,							SCREAMING_SNAKE_CASE__     ,							)
                    a_					:		Tuple							=  kwargs.pop('feature_extractor'     )

             a_					:		Tuple							=  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__(SCREAMING_SNAKE_CASE__     ,							SCREAMING_SNAKE_CASE__     )
      def __call__(       self				:       List[Any]     ,							SCREAMING_SNAKE_CASE__				:       Optional[Any]=None     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=None     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=None     ,							**SCREAMING_SNAKE_CASE__				:       str     )		->			Optional[Any]:

             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:
                    a_					:		List[str]							=  self.tokenizer(SCREAMING_SNAKE_CASE__     ,							return_tensors=SCREAMING_SNAKE_CASE__     ,							**SCREAMING_SNAKE_CASE__     )

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

             if text is not None and images is not None:
                    a_					:		Dict							=  image_features.pixel_values
                    return encoding
             elif text is not None:
                    return encoding
             else:
                    return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE__     )     ,							tensor_type=SCREAMING_SNAKE_CASE__     )
      def        SCREAMING_SNAKE_CASE							(       self				:       Any     ,							*SCREAMING_SNAKE_CASE__				:       List[Any]     ,							**SCREAMING_SNAKE_CASE__				:       Optional[int]     )		->			List[Any]:
             return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE__     ,							**SCREAMING_SNAKE_CASE__     )
      def        SCREAMING_SNAKE_CASE							(       self				:       Optional[Any]     ,							*SCREAMING_SNAKE_CASE__				:       List[Any]     ,							**SCREAMING_SNAKE_CASE__				:       Dict     )		->			Optional[Any]:
             return self.tokenizer.decode(*SCREAMING_SNAKE_CASE__     ,							**SCREAMING_SNAKE_CASE__     )
      @property
      def        SCREAMING_SNAKE_CASE							(       self				:       List[Any]     )		->			Any:
             a_					:		str							=  self.tokenizer.model_input_names
             a_					:		Tuple							=  self.image_processor.model_input_names
             return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names     )     )
      @property
      def        SCREAMING_SNAKE_CASE							(       self				:       str     )		->			str:
             warnings.warn(
                 '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'     ,							SCREAMING_SNAKE_CASE__     ,							)
             return self.image_processor_class

      @property
      def        SCREAMING_SNAKE_CASE							(       self				:       str     )		->			Tuple:
             warnings.warn(
                 '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'     ,							SCREAMING_SNAKE_CASE__     ,							)
             return self.image_processor


