




import warnings

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


UpperCAmelCase_		:				List[str]									=     logging.get_logger(__name__)

UpperCAmelCase_		:				int									=     {
    "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json",
    "xlnet-large-cased": "https://huggingface.co/xlnet-large-cased/resolve/main/config.json",
}




class 		__A      (			UpperCamelCase__			):
						UpperCamelCase     						=					"""xlnet"""
						UpperCamelCase     						=					["""mems"""]
						UpperCamelCase     						=					{
						    """n_token""": """vocab_size""",  # Backward compatibility
						    """hidden_size""": """d_model""",
						    """num_attention_heads""": """n_head""",
						    """num_hidden_layers""": """n_layer""",
						}

						def __init__(		self   :Union[str, Any]    , __snake_case   :Optional[Any]=3_20_00    , __snake_case   :int=10_24    , __snake_case   :int=24    , __snake_case   :List[Any]=16    , __snake_case   :Optional[Any]=40_96    , __snake_case   :List[str]="gelu"    , __snake_case   :List[str]=True    , __snake_case   :Tuple="bi"    , __snake_case   :Optional[Any]=0.02    , __snake_case   :Optional[int]=1E-12    , __snake_case   :Optional[Any]=0.1    , __snake_case   :Dict=5_12    , __snake_case   :List[str]=None    , __snake_case   :Dict=True    , __snake_case   :Any=False    , __snake_case   :Optional[Any]=False    , __snake_case   :Union[str, Any]=-1    , __snake_case   :Union[str, Any]=False    , __snake_case   :List[Any]="last"    , __snake_case   :List[str]=True    , __snake_case   :Dict="tanh"    , __snake_case   :Tuple=0.1    , __snake_case   :Tuple=5    , __snake_case   :List[Any]=5    , __snake_case   :Union[str, Any]=5    , __snake_case   :List[Any]=1    , __snake_case   :Optional[int]=2    , **__snake_case   :List[str]    , ):
										'''simple docstring'''

										__magic_name__	:	List[Any]								=vocab_size
										__magic_name__	:	Optional[Any]								=d_model
										__magic_name__	:	int								=n_layer
										__magic_name__	:	int								=n_head
										if d_model % n_head != 0:
														raise ValueError(f"'d_model % n_head' ({d_model % n_head}) should be equal to 0" )
										if "d_head" in kwargs:
														if kwargs["d_head"] != d_model // n_head:
																		raise ValueError(
																		    f"`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})" )
										__magic_name__	:	Tuple								=d_model // n_head
										__magic_name__	:	Optional[int]								=ff_activation
										__magic_name__	:	Union[str, Any]								=d_inner
										__magic_name__	:	Optional[Any]								=untie_r
										__magic_name__	:	Tuple								=attn_type

										__magic_name__	:	Any								=initializer_range
										__magic_name__	:	List[str]								=layer_norm_eps

										__magic_name__	:	List[str]								=dropout
										__magic_name__	:	str								=mem_len
										__magic_name__	:	Optional[Any]								=reuse_len
										__magic_name__	:	List[str]								=bi_data
										__magic_name__	:	int								=clamp_len
										__magic_name__	:	Optional[Any]								=same_length

										__magic_name__	:	int								=summary_type
										__magic_name__	:	int								=summary_use_proj
										__magic_name__	:	Union[str, Any]								=summary_activation
										__magic_name__	:	Dict								=summary_last_dropout
										__magic_name__	:	Tuple								=start_n_top
										__magic_name__	:	str								=end_n_top

										__magic_name__	:	Optional[int]								=bos_token_id
										__magic_name__	:	str								=pad_token_id
										__magic_name__	:	Tuple								=eos_token_id

										if "use_cache" in kwargs:
														warnings.warn(
														    """The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`"""
														    """ instead."""    , __snake_case    , )
														__magic_name__	:	Optional[Any]								=kwargs["""use_cache"""]

										__magic_name__	:	List[str]								=use_mems_eval
										__magic_name__	:	List[Any]								=use_mems_train
										super().__init__(pad_token_id=__snake_case    , bos_token_id=__snake_case    , eos_token_id=__snake_case    , **__snake_case )

						@property
						def     A__						(		self   :str ):
										'''simple docstring'''

										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     A__						(		self   :Tuple    , __snake_case   :Tuple ):
										'''simple docstring'''

										raise NotImplementedError(
										    f"The model {self.model_type} is one of the few models that has no sequence length limit." )










import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin




class 		__A      (			UpperCamelCase__			):
						UpperCamelCase     						=					"""Speech2TextFeatureExtractor"""
						UpperCamelCase     						=					"""Speech2TextTokenizer"""

						def __init__(		self   :Any    , __snake_case   :int    , __snake_case   :Any ):
										'''simple docstring'''

										super().__init__(__snake_case    , __snake_case )
										__magic_name__	:	Optional[int]								=self.feature_extractor
										__magic_name__	:	Any								=False

						def __call__(		self   :Tuple    , *__snake_case   :List[str]    , **__snake_case   :List[str] ):
										'''simple docstring'''

										if self._in_target_context_manager:
														return self.current_processor(*__snake_case    , **__snake_case )

										if "raw_speech" in kwargs:
														warnings.warn("""Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.""" )
														__magic_name__	:	Tuple								=kwargs.pop("""raw_speech""" )
										else:
														__magic_name__	:	List[Any]								=kwargs.pop("""audio"""    , __snake_case )
										__magic_name__	:	Union[str, Any]								=kwargs.pop("""sampling_rate"""    , __snake_case )
										__magic_name__	:	Dict								=kwargs.pop("""text"""    , __snake_case )
										if len(__snake_case ) > 0:
														__magic_name__	:	Union[str, Any]								=args[0]
														__magic_name__	:	int								=args[1:]

										if audio is None and text is None:
														raise ValueError("""You need to specify either an `audio` or `text` input to process.""" )

										if audio is not None:
														__magic_name__	:	List[str]								=self.feature_extractor(__snake_case    , *__snake_case    , sampling_rate=__snake_case    , **__snake_case )
										if text is not None:
														__magic_name__	:	Any								=self.tokenizer(__snake_case    , **__snake_case )

										if text is None:
														return inputs
										elif audio is None:
														return encodings
										else:
														__magic_name__	:	List[str]								=encodings["""input_ids"""]
														return inputs

						def     A__						(		self   :List[Any]    , *__snake_case   :str    , **__snake_case   :List[str] ):
										'''simple docstring'''

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

						def     A__						(		self   :int    , *__snake_case   :int    , **__snake_case   :Optional[int] ):
										'''simple docstring'''

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


						@contextmanager
						def     A__						(		self   :int ):
										'''simple docstring'''

										warnings.warn(
										    """`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your """
										    """labels by using the argument `text` of the regular `__call__` method (either in the same call as """
										    """your audio inputs, or in a separate call.""" )
										__magic_name__	:	int								=True
										__magic_name__	:	List[Any]								=self.tokenizer
										yield
										__magic_name__	:	List[Any]								=self.feature_extractor
										__magic_name__	:	str								=False




