
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer





class    __A(					UpperCAmelCase							):
					SCREAMING_SNAKE_CASE           =     '''Wav2Vec2FeatureExtractor'''
					SCREAMING_SNAKE_CASE           =     '''AutoTokenizer'''

					def __init__(						self       :  Any ,       __UpperCamelCase       :  Dict ,       __UpperCamelCase       :  Optional[Any] ):
												super().__init__(__UpperCamelCase ,       __UpperCamelCase )
												lowerCamelCase_					=       self.feature_extractor
												lowerCamelCase_					=       False

					@classmethod
					def  lowercase__   (						cls       :  Any ,       __UpperCamelCase       :  int ,       **__UpperCamelCase       :  Any ):
												try:
																			return super().from_pretrained(__UpperCamelCase ,       **__UpperCamelCase )
												except OSError:
																			warnings.warn(
																			    F'''Loading a tokenizer inside {cls.__name__} from a config that does not'''
																			    """ include a `tokenizer_class` attribute is deprecated and will be """
																			    """removed in v5. Please add `'tokenizer_class': 'Wav2Vec2CTCTokenizer'`"""
																			    """ attribute to either your `config.json` or `tokenizer_config.json` """
																			    """file to suppress this warning: """ ,       __UpperCamelCase ,       )

																			lowerCamelCase_					=       WavaVecaFeatureExtractor.from_pretrained(__UpperCamelCase ,       **__UpperCamelCase )
																			lowerCamelCase_					=       WavaVecaCTCTokenizer.from_pretrained(__UpperCamelCase ,       **__UpperCamelCase )

																			return cls(feature_extractor=__UpperCamelCase ,       tokenizer=__UpperCamelCase )

					def __call__(						self       :  str ,       *__UpperCamelCase       :  Dict ,       **__UpperCamelCase       :  Union[str, Any] ):
												# For backward compatibility
												if self._in_target_context_manager:
																			return self.current_processor(*__UpperCamelCase ,       **__UpperCamelCase )

												if "raw_speech" in kwargs:
																			warnings.warn("""Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.""" )
																			lowerCamelCase_					=       kwargs.pop("""raw_speech""" )
												else:
																			lowerCamelCase_					=       kwargs.pop("""audio""" ,       __UpperCamelCase )
												lowerCamelCase_					=       kwargs.pop("""sampling_rate""" ,       __UpperCamelCase )
												lowerCamelCase_					=       kwargs.pop("""text""" ,       __UpperCamelCase )
												if len(__UpperCamelCase ) > 0:
																			lowerCamelCase_					=       args[0]
																			lowerCamelCase_					=       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:
																			lowerCamelCase_					=       self.feature_extractor(__UpperCamelCase ,       *__UpperCamelCase ,       sampling_rate=__UpperCamelCase ,       **__UpperCamelCase )
												if text is not None:
																			lowerCamelCase_					=       self.tokenizer(__UpperCamelCase ,       **__UpperCamelCase )

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

					def  lowercase__   (						self       :  str ,       *__UpperCamelCase       :  Optional[Any] ,       **__UpperCamelCase       :  Union[str, Any] ):
												# For backward compatibility
												if self._in_target_context_manager:
																			return self.current_processor.pad(*__UpperCamelCase ,       **__UpperCamelCase )

												lowerCamelCase_					=       kwargs.pop("""input_features""" ,       __UpperCamelCase )
												lowerCamelCase_					=       kwargs.pop("""labels""" ,       __UpperCamelCase )
												if len(__UpperCamelCase ) > 0:
																			lowerCamelCase_					=       args[0]
																			lowerCamelCase_					=       args[1:]

												if input_features is not None:
																			lowerCamelCase_					=       self.feature_extractor.pad(__UpperCamelCase ,       *__UpperCamelCase ,       **__UpperCamelCase )
												if labels is not None:
																			lowerCamelCase_					=       self.tokenizer.pad(__UpperCamelCase ,       **__UpperCamelCase )

												if labels is None:
																			return input_features
												elif input_features is None:
																			return labels
												else:
																			lowerCamelCase_					=       labels["""input_ids"""]
																			return input_features

					def  lowercase__   (						self       :  Optional[Any] ,       *__UpperCamelCase       :  Tuple ,       **__UpperCamelCase       :  List[str] ):
												return self.tokenizer.batch_decode(*__UpperCamelCase ,       **__UpperCamelCase )

					def  lowercase__   (						self       :  Optional[Any] ,       *__UpperCamelCase       :  List[Any] ,       **__UpperCamelCase       :  int ):
												return self.tokenizer.decode(*__UpperCamelCase ,       **__UpperCamelCase )



					@contextmanager
					def  lowercase__   (						self       :  Any ):
												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.""" )
												lowerCamelCase_					=       True
												lowerCamelCase_					=       self.tokenizer
												yield
												lowerCamelCase_					=       self.feature_extractor
												lowerCamelCase_					=       False







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


lowercase   =	logging.get_logger(__name__)

lowercase   =	{
    '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json''',
}





class    __A(					UpperCAmelCase							):
					SCREAMING_SNAKE_CASE           =     '''gpt_neox_japanese'''

					def __init__(						self       :  Union[str, Any] ,       __UpperCamelCase       :  str=3_2_0_0_0 ,       __UpperCamelCase       :  List[Any]=2_5_6_0 ,       __UpperCamelCase       :  Any=3_2 ,       __UpperCamelCase       :  List[str]=3_2 ,       __UpperCamelCase       :  List[str]=4 ,       __UpperCamelCase       :  Dict="gelu" ,       __UpperCamelCase       :  List[Any]=1.00 ,       __UpperCamelCase       :  Any=1_0_0_0_0 ,       __UpperCamelCase       :  Optional[Any]=2_0_4_8 ,       __UpperCamelCase       :  Tuple=0.02 ,       __UpperCamelCase       :  List[str]=1E-5 ,       __UpperCamelCase       :  str=True ,       __UpperCamelCase       :  str=3_1_9_9_6 ,       __UpperCamelCase       :  int=3_1_9_9_9 ,       __UpperCamelCase       :  Optional[Any]=0.1 ,       __UpperCamelCase       :  Tuple=0.0 ,       **__UpperCamelCase       :  List[str] ,       ):
												super().__init__(bos_token_id=__UpperCamelCase ,       eos_token_id=__UpperCamelCase ,       **__UpperCamelCase )
												lowerCamelCase_					=       vocab_size
												lowerCamelCase_					=       max_position_embeddings
												lowerCamelCase_					=       hidden_size
												lowerCamelCase_					=       num_hidden_layers
												lowerCamelCase_					=       num_attention_heads
												lowerCamelCase_					=       intermediate_multiple_size
												lowerCamelCase_					=       hidden_act
												lowerCamelCase_					=       rotary_pct
												lowerCamelCase_					=       rotary_emb_base
												lowerCamelCase_					=       initializer_range
												lowerCamelCase_					=       layer_norm_eps
												lowerCamelCase_					=       use_cache
												lowerCamelCase_					=       attention_dropout
												lowerCamelCase_					=       hidden_dropout





