





'''simple docstring'''






import functools
import operator

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


snake_case_     =	logging.get_logger(__name__)

snake_case_     =	{
    'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}


class   _lowercase						(							a				):
   _UpperCamelCase       		=   """wav2vec2"""


   def __init__( self    ,   _UpperCAmelCase=32    ,   _UpperCAmelCase=768    ,   _UpperCAmelCase=12    ,   _UpperCAmelCase=12    ,   _UpperCAmelCase=3_072    ,   _UpperCAmelCase="gelu"    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=0.02    ,   _UpperCAmelCase=1E-5    ,   _UpperCAmelCase="group"    ,   _UpperCAmelCase="gelu"    ,   _UpperCAmelCase=(512, 512, 512, 512, 512, 512, 512)    ,   _UpperCAmelCase=(5, 2, 2, 2, 2, 2, 2)    ,   _UpperCAmelCase=(10, 3, 3, 3, 3, 2, 2)    ,   _UpperCAmelCase=False    ,   _UpperCAmelCase=128    ,   _UpperCAmelCase=16    ,   _UpperCAmelCase=False    ,   _UpperCAmelCase=True    ,   _UpperCAmelCase=0.05    ,   _UpperCAmelCase=10    ,   _UpperCAmelCase=2    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=10    ,   _UpperCAmelCase=0    ,   _UpperCAmelCase=320    ,   _UpperCAmelCase=2    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase=100    ,   _UpperCAmelCase=256    ,   _UpperCAmelCase=256    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase="sum"    ,   _UpperCAmelCase=False    ,   _UpperCAmelCase=False    ,   _UpperCAmelCase=256    ,   _UpperCAmelCase=(512, 512, 512, 512, 1_500)    ,   _UpperCAmelCase=(5, 3, 3, 1, 1)    ,   _UpperCAmelCase=(1, 2, 3, 1, 1)    ,   _UpperCAmelCase=512    ,   _UpperCAmelCase=0    ,   _UpperCAmelCase=1    ,   _UpperCAmelCase=2    ,   _UpperCAmelCase=False    ,   _UpperCAmelCase=3    ,   _UpperCAmelCase=2    ,   _UpperCAmelCase=3    ,   _UpperCAmelCase=None    ,   _UpperCAmelCase=None    ,   **_UpperCAmelCase    ,   ):
       super().__init__(**__A    ,   pad_token_id=__A    ,   bos_token_id=__A    ,   eos_token_id=__A					)
       A       :       int							=						hidden_size
       A       :       List[Any]							=						feat_extract_norm
       A       :       Optional[Any]							=						feat_extract_activation
       A       :       List[str]							=						list(__A					)
       A       :       Optional[int]							=						list(__A					)
       A       :       int							=						list(__A					)
       A       :       str							=						conv_bias
       A       :       List[Any]							=						num_conv_pos_embeddings
       A       :       Any							=						num_conv_pos_embedding_groups
       A       :       Optional[int]							=						len(self.conv_dim					)
       A       :       Optional[int]							=						num_hidden_layers
       A       :       Any							=						intermediate_size
       A       :       Tuple							=						hidden_act
       A       :       Tuple							=						num_attention_heads
       A       :       Any							=						hidden_dropout
       A       :       List[Any]							=						attention_dropout
       A       :       List[Any]							=						activation_dropout
       A       :       Any							=						feat_proj_dropout
       A       :       Dict							=						final_dropout
       A       :       Optional[int]							=						layerdrop
       A       :       Optional[Any]							=						layer_norm_eps
       A       :       Tuple							=						initializer_range
       A       :       List[str]							=						vocab_size
       A       :       Dict							=						do_stable_layer_norm
       A       :       Union[str, Any]							=						use_weighted_layer_sum

       if (
           (len(self.conv_stride					) != self.num_feat_extract_layers)
           or (len(self.conv_kernel					) != self.num_feat_extract_layers)
           or (len(self.conv_dim					) != self.num_feat_extract_layers)
       ):
           raise ValueError(
               '''Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='''
               ''' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='''
               f''' {len(self.conv_dim					)}`, `len(config.conv_stride) = {len(self.conv_stride					)}`,'''
               f''' `len(config.conv_kernel) = {len(self.conv_kernel					)}`.'''					)

       # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
       A       :       int							=						apply_spec_augment
       A       :       Optional[Any]							=						mask_time_prob
       A       :       List[Any]							=						mask_time_length
       A       :       List[Any]							=						mask_time_min_masks
       A       :       List[Any]							=						mask_feature_prob
       A       :       Optional[Any]							=						mask_feature_length
       A       :       int							=						mask_feature_min_masks

       # parameters for pretraining with codevector quantized representations
       A       :       List[Any]							=						num_codevectors_per_group
       A       :       Tuple							=						num_codevector_groups
       A       :       int							=						contrastive_logits_temperature
       A       :       str							=						feat_quantizer_dropout
       A       :       List[str]							=						num_negatives
       A       :       Optional[Any]							=						codevector_dim
       A       :       Optional[int]							=						proj_codevector_dim
       A       :       int							=						diversity_loss_weight

       # ctc loss
       A       :       Any							=						ctc_loss_reduction
       A       :       int							=						ctc_zero_infinity

       # adapter
       A       :       Any							=						add_adapter
       A       :       Tuple							=						adapter_kernel_size
       A       :       Union[str, Any]							=						adapter_stride
       A       :       Dict							=						num_adapter_layers
       A       :       Optional[Any]							=						output_hidden_size or hidden_size
       A       :       int							=						adapter_attn_dim

       # SequenceClassification-specific parameter. Feel free to ignore for other classes.
       A       :       List[Any]							=						classifier_proj_size

       # XVector-specific parameters. Feel free to ignore for other classes.
       A       :       int							=						list(__A					)
       A       :       Optional[Any]							=						list(__A					)
       A       :       List[Any]							=						list(__A					)
       A       :       str							=						xvector_output_dim


   @property
   def 					snake_case				( self					):
       return functools.reduce(operator.mul    ,   self.conv_stride    ,   1					)










'''simple docstring'''






import importlib.util
import os
import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import (
    is_accelerate_available,
    is_flax_available,
    is_safetensors_available,
    is_tf_available,
    is_torch_available,
)
from . import BaseTransformersCLICommand
def 							_lowerCamelCase(  UpperCamelCase__    : Optional[int]		)		->  List[str]:
    return EnvironmentCommand()
def 							_lowerCamelCase(  UpperCamelCase__    : List[Any]		)		->  Tuple:
    return EnvironmentCommand(args.accelerate_config_file		)





class   _lowercase						(							a				):


   @staticmethod
   def 					snake_case				( _UpperCAmelCase					):
       A       :       Optional[Any]							=						parser.add_parser('''env'''					)
       download_parser.set_defaults(func=_UpperCAmelCase					)
       download_parser.add_argument(
           '''--accelerate-config_file'''    ,   default=_UpperCAmelCase    ,   help='''The accelerate config file to use for the default values in the launching script.'''    ,   )
       download_parser.set_defaults(func=_UpperCAmelCase					)


   def __init__( self    ,   _UpperCAmelCase    ,   *_UpperCAmelCase					):
       A       :       Any							=						accelerate_config_file


   def 					snake_case				( self					):
       A       :       Any							=						'''not installed'''
       if is_safetensors_available():
           import safetensors

           A       :       Dict							=						safetensors.__version__
       elif importlib.util.find_spec('''safetensors'''					) is not None:
           import safetensors

           A       :       int							=						f'''{safetensors.__version__} but is ignored because of PyTorch version too old.'''

       A       :       Tuple							=						'''not installed'''
       A       :       Tuple							=						'''not found'''
       if is_accelerate_available():
           import accelerate
           from accelerate.commands.config import default_config_file, load_config_from_file

           A       :       Any							=						accelerate.__version__
           # Get the default from the config file.
           if self._accelerate_config_file is not None or os.path.isfile(_UpperCAmelCase					):
               A       :       int							=						load_config_from_file(self._accelerate_config_file					).to_dict()

           A       :       Tuple							=						(
               '''\n'''.join([f'''\t- {prop}: {val}''' for prop, val in accelerate_config.items()]					)
               if isinstance(_UpperCAmelCase    ,   _UpperCAmelCase					)
               else f'''\t{accelerate_config}'''
           )

       A       :       str							=						'''not installed'''
       A       :       Optional[Any]							=						'''NA'''
       if is_torch_available():
           import torch

           A       :       Optional[int]							=						torch.__version__
           A       :       List[Any]							=						torch.cuda.is_available()

       A       :       Dict							=						'''not installed'''
       A       :       Any							=						'''NA'''
       if is_tf_available():
           import tensorflow as tf

           A       :       Optional[int]							=						tf.__version__
           try:
               # deprecated in v2.1
               A       :       int							=						tf.test.is_gpu_available()
           except AttributeError:
               # returns list of devices, convert to bool
               A       :       Optional[int]							=						bool(tf.config.list_physical_devices('''GPU'''					)					)

       A       :       str							=						'''not installed'''
       A       :       Dict							=						'''not installed'''
       A       :       int							=						'''not installed'''
       A       :       Tuple							=						'''NA'''
       if is_flax_available():
           import flax
           import jax
           import jaxlib

           A       :       Any							=						flax.__version__
           A       :       Tuple							=						jax.__version__
           A       :       int							=						jaxlib.__version__
           A       :       List[Any]							=						jax.lib.xla_bridge.get_backend().platform

       A       :       Union[str, Any]							=						{
           '''`transformers` version''': version,
           '''Platform''': platform.platform(),
           '''Python version''': platform.python_version(),
           '''Huggingface_hub version''': huggingface_hub.__version__,
           '''Safetensors version''': f'''{safetensors_version}''',
           '''Accelerate version''': f'''{accelerate_version}''',
           '''Accelerate config''': f'''{accelerate_config_str}''',
           '''PyTorch version (GPU?)''': f'''{pt_version} ({pt_cuda_available})''',
           '''Tensorflow version (GPU?)''': f'''{tf_version} ({tf_cuda_available})''',
           '''Flax version (CPU?/GPU?/TPU?)''': f'''{flax_version} ({jax_backend})''',
           '''Jax version''': f'''{jax_version}''',
           '''JaxLib version''': f'''{jaxlib_version}''',
           '''Using GPU in script?''': '''<fill in>''',
           '''Using distributed or parallel set-up in script?''': '''<fill in>''',
       }

       print('''\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n'''					)
       print(self.format_dict(_UpperCAmelCase					)					)

       return info


   @staticmethod
   def 					snake_case				( _UpperCAmelCase					):
       return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"
