


import warnings
from contextlib import contextmanager

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






class   __lowercase				(  __snake_case  ):
      UpperCamelCase								=       '''Wav2Vec2FeatureExtractor'''
      UpperCamelCase								=       '''AutoTokenizer'''





      def __init__(		self						:					int					,       __lowerCamelCase						:					List[str]					,       __lowerCamelCase						:					Optional[Any]       )    ->   List[Any]:






         """simple docstring"""







         super().__init__(__lowerCamelCase					,       __lowerCamelCase       )
         UpperCAmelCase							=     self.feature_extractor
         UpperCAmelCase							=     False





      @classmethod
      def        _lowercase				(		cls						:					List[str]					,       __lowerCamelCase						:					List[str]					,       **__lowerCamelCase						:					Dict       )    ->   int:






         """simple docstring"""







         try:
            return super().from_pretrained(__lowerCamelCase					,       **__lowerCamelCase       )
         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: """					,       __lowerCamelCase					,       )

            UpperCAmelCase							=     WavaVecaFeatureExtractor.from_pretrained(__lowerCamelCase					,       **__lowerCamelCase       )
            UpperCAmelCase							=     WavaVecaCTCTokenizer.from_pretrained(__lowerCamelCase					,       **__lowerCamelCase       )

            return cls(feature_extractor=__lowerCamelCase					,       tokenizer=__lowerCamelCase       )





      def __call__(		self						:					Optional[Any]					,       *__lowerCamelCase						:					Tuple					,       **__lowerCamelCase						:					str       )    ->   Tuple:






         """simple docstring"""







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

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

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





      def        _lowercase				(		self						:					Union[str, Any]					,       *__lowerCamelCase						:					List[str]					,       **__lowerCamelCase						:					Optional[Any]       )    ->   Dict:






         """simple docstring"""







         if self._in_target_context_manager:
            return self.current_processor.pad(*__lowerCamelCase					,       **__lowerCamelCase       )

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

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

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





      def        _lowercase				(		self						:					int					,       *__lowerCamelCase						:					Dict					,       **__lowerCamelCase						:					Optional[int]       )    ->   Optional[int]:






         """simple docstring"""







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





      def        _lowercase				(		self						:					Any					,       *__lowerCamelCase						:					Tuple					,       **__lowerCamelCase						:					Dict       )    ->   List[Any]:






         """simple docstring"""







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





      @contextmanager
      def        _lowercase				(		self						:					Optional[Any]       )    ->   Any:






         """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."""       )
         UpperCAmelCase							=     True
         UpperCAmelCase							=     self.tokenizer
         yield
         UpperCAmelCase							=     self.feature_extractor
         UpperCAmelCase							=     False







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


__a     =			logging.get_logger(__name__)

__a     =			{
    """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""",
}






class   __lowercase				(  __snake_case  ):
      UpperCamelCase								=       '''nllb-moe'''
      UpperCamelCase								=       ['''past_key_values''']
      UpperCamelCase								=       {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}





      def __init__(		self						:					Optional[int]					,       __lowerCamelCase						:					Optional[Any]=1_2_8_1_1_2					,       __lowerCamelCase						:					Dict=1_0_2_4					,       __lowerCamelCase						:					Optional[int]=1_2					,       __lowerCamelCase						:					Union[str, Any]=4_0_9_6					,       __lowerCamelCase						:					List[str]=1_6					,       __lowerCamelCase						:					List[str]=1_2					,       __lowerCamelCase						:					int=4_0_9_6					,       __lowerCamelCase						:					Tuple=1_6					,       __lowerCamelCase						:					str=0.05					,       __lowerCamelCase						:					List[str]=0.05					,       __lowerCamelCase						:					List[Any]=True					,       __lowerCamelCase						:					Tuple=True					,       __lowerCamelCase						:					str="relu"					,       __lowerCamelCase						:					Dict=1_0_2_4					,       __lowerCamelCase						:					List[str]=0.1					,       __lowerCamelCase						:					Optional[int]=0.1					,       __lowerCamelCase						:					List[Any]=0.0					,       __lowerCamelCase						:					Optional[Any]=0.02					,       __lowerCamelCase						:					Dict=2					,       __lowerCamelCase						:					Union[str, Any]=True					,       __lowerCamelCase						:					Any=False					,       __lowerCamelCase						:					Tuple="float32"					,       __lowerCamelCase						:					Any=False					,       __lowerCamelCase						:					Optional[int]=1_2_8					,       __lowerCamelCase						:					List[str]=6_4					,       __lowerCamelCase						:					List[Any]=4					,       __lowerCamelCase						:					Tuple=4					,       __lowerCamelCase						:					str=0.001					,       __lowerCamelCase						:					Optional[int]=0.001					,       __lowerCamelCase						:					Tuple="all"					,       __lowerCamelCase						:					Any=False					,       __lowerCamelCase						:					Optional[int]=False					,       __lowerCamelCase						:					List[str]=1.0					,       __lowerCamelCase						:					Dict=0.2					,       __lowerCamelCase						:					Union[str, Any]=1					,       __lowerCamelCase						:					int=0					,       __lowerCamelCase						:					Dict=2					,       __lowerCamelCase						:					int=False					,       **__lowerCamelCase						:					str					,       )    ->   int:






         """simple docstring"""







         UpperCAmelCase							=     vocab_size
         UpperCAmelCase							=     max_position_embeddings
         UpperCAmelCase							=     d_model
         UpperCAmelCase							=     encoder_ffn_dim
         UpperCAmelCase							=     encoder_layers
         UpperCAmelCase							=     encoder_attention_heads
         UpperCAmelCase							=     decoder_ffn_dim
         UpperCAmelCase							=     decoder_layers
         UpperCAmelCase							=     decoder_attention_heads
         UpperCAmelCase							=     dropout
         UpperCAmelCase							=     attention_dropout
         UpperCAmelCase							=     activation_dropout
         UpperCAmelCase							=     activation_function
         UpperCAmelCase							=     init_std
         UpperCAmelCase							=     encoder_layerdrop
         UpperCAmelCase							=     decoder_layerdrop
         UpperCAmelCase							=     use_cache
         UpperCAmelCase							=     encoder_layers
         UpperCAmelCase							=     scale_embedding  # scale factor will be sqrt(d_model) if True
         UpperCAmelCase							=     router_z_loss_coef
         UpperCAmelCase							=     router_aux_loss_coef
         UpperCAmelCase							=     decoder_sparse_step
         UpperCAmelCase							=     encoder_sparse_step
         UpperCAmelCase							=     num_experts
         UpperCAmelCase							=     expert_capacity
         UpperCAmelCase							=     router_bias
         if router_dtype not in ["float32", "float16", "bfloat16"]:
            raise ValueError(F"""`router_dtype` must be one of 'float32', 'float16' or 'bfloat16', got {router_dtype}"""       )
         UpperCAmelCase							=     router_dtype

         UpperCAmelCase							=     router_ignore_padding_tokens
         UpperCAmelCase							=     batch_prioritized_routing
         UpperCAmelCase							=     second_expert_policy
         UpperCAmelCase							=     normalize_router_prob_before_dropping
         UpperCAmelCase							=     moe_eval_capacity_token_fraction
         UpperCAmelCase							=     moe_token_dropout
         UpperCAmelCase							=     output_router_logits
         super().__init__(
             pad_token_id=__lowerCamelCase					,       bos_token_id=__lowerCamelCase					,       eos_token_id=__lowerCamelCase					,       is_encoder_decoder=__lowerCamelCase					,       decoder_start_token_id=__lowerCamelCase					,       **__lowerCamelCase					,       )



