
import functools
import operator

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


__magic_name__            =  logging.get_logger(__name__)

__magic_name__            =  {
    '''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 					_SCREAMING_SNAKE_CASE  (      __UpperCamelCase ):
      _A						:		Optional[int]    	=     'wav2vec2'
      def __init__(			self		,	lowerCamelCase=32		,	lowerCamelCase=7_68		,	lowerCamelCase=12		,	lowerCamelCase=12		,	lowerCamelCase=30_72		,	lowerCamelCase="gelu"		,	lowerCamelCase=0.1		,	lowerCamelCase=0.1		,	lowerCamelCase=0.1		,	lowerCamelCase=0.0		,	lowerCamelCase=0.0		,	lowerCamelCase=0.1		,	lowerCamelCase=0.1		,	lowerCamelCase=0.0_2		,	lowerCamelCase=1e-5		,	lowerCamelCase="group"		,	lowerCamelCase="gelu"		,	lowerCamelCase=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)		,	lowerCamelCase=(5, 2, 2, 2, 2, 2, 2)		,	lowerCamelCase=(10, 3, 3, 3, 3, 2, 2)		,	lowerCamelCase=False		,	lowerCamelCase=1_28		,	lowerCamelCase=16		,	lowerCamelCase=False		,	lowerCamelCase=True		,	lowerCamelCase=0.0_5		,	lowerCamelCase=10		,	lowerCamelCase=2		,	lowerCamelCase=0.0		,	lowerCamelCase=10		,	lowerCamelCase=0		,	lowerCamelCase=3_20		,	lowerCamelCase=2		,	lowerCamelCase=0.1		,	lowerCamelCase=1_00		,	lowerCamelCase=2_56		,	lowerCamelCase=2_56		,	lowerCamelCase=0.1		,	lowerCamelCase="sum"		,	lowerCamelCase=False		,	lowerCamelCase=False		,	lowerCamelCase=2_56		,	lowerCamelCase=(5_12, 5_12, 5_12, 5_12, 15_00)		,	lowerCamelCase=(5, 3, 3, 1, 1)		,	lowerCamelCase=(1, 2, 3, 1, 1)		,	lowerCamelCase=5_12		,	lowerCamelCase=0		,	lowerCamelCase=1		,	lowerCamelCase=2		,	lowerCamelCase=False		,	lowerCamelCase=3		,	lowerCamelCase=2		,	lowerCamelCase=3		,	lowerCamelCase=None		,	lowerCamelCase=None		,	**lowerCamelCase		,	):
          super().__init__(**lowerCamelCase		,	pad_token_id=lowerCamelCase		,	bos_token_id=lowerCamelCase		,	eos_token_id=lowerCamelCase )
          snake_case__						=				hidden_size
          snake_case__						=				feat_extract_norm
          snake_case__						=				feat_extract_activation
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				conv_bias
          snake_case__						=				num_conv_pos_embeddings
          snake_case__						=				num_conv_pos_embedding_groups
          snake_case__						=				len(self.conv_dim )
          snake_case__						=				num_hidden_layers
          snake_case__						=				intermediate_size
          snake_case__						=				hidden_act
          snake_case__						=				num_attention_heads
          snake_case__						=				hidden_dropout
          snake_case__						=				attention_dropout
          snake_case__						=				activation_dropout
          snake_case__						=				feat_proj_dropout
          snake_case__						=				final_dropout
          snake_case__						=				layerdrop
          snake_case__						=				layer_norm_eps
          snake_case__						=				initializer_range
          snake_case__						=				vocab_size
          snake_case__						=				do_stable_layer_norm
          snake_case__						=				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
          snake_case__						=				apply_spec_augment
          snake_case__						=				mask_time_prob
          snake_case__						=				mask_time_length
          snake_case__						=				mask_time_min_masks
          snake_case__						=				mask_feature_prob
          snake_case__						=				mask_feature_length
          snake_case__						=				mask_feature_min_masks

          # parameters for pretraining with codevector quantized representations
          snake_case__						=				num_codevectors_per_group
          snake_case__						=				num_codevector_groups
          snake_case__						=				contrastive_logits_temperature
          snake_case__						=				feat_quantizer_dropout
          snake_case__						=				num_negatives
          snake_case__						=				codevector_dim
          snake_case__						=				proj_codevector_dim
          snake_case__						=				diversity_loss_weight

          # ctc loss
          snake_case__						=				ctc_loss_reduction
          snake_case__						=				ctc_zero_infinity

          # adapter
          snake_case__						=				add_adapter
          snake_case__						=				adapter_kernel_size
          snake_case__						=				adapter_stride
          snake_case__						=				num_adapter_layers
          snake_case__						=				output_hidden_size or hidden_size
          snake_case__						=				adapter_attn_dim

          # SequenceClassification-specific parameter. Feel free to ignore for other classes.
          snake_case__						=				classifier_proj_size

          # XVector-specific parameters. Feel free to ignore for other classes.
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				list(lowerCamelCase )
          snake_case__						=				xvector_output_dim



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





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 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase							):
    return EnvironmentCommand()





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase							):
    return EnvironmentCommand(args.accelerate_config_file							)





class 					_SCREAMING_SNAKE_CASE  (      __UpperCamelCase ):
      @staticmethod
      def A_			(			lowerCamelCase ):
          snake_case__						=				parser.add_parser("env" )
          download_parser.set_defaults(func=lowerCamelCase )
          download_parser.add_argument(
              "--accelerate-config_file"		,	default=lowerCamelCase		,	help="The accelerate config file to use for the default values in the launching script."		,	)
          download_parser.set_defaults(func=lowerCamelCase )
      def __init__(			self		,	lowerCamelCase		,	*lowerCamelCase ):
          snake_case__						=				accelerate_config_file
      def A_			(			self ):
          snake_case__						=				"not installed"
          if is_safetensors_available():
              import safetensors

              snake_case__						=				safetensors.__version__
          elif importlib.util.find_spec("safetensors" ) is not None:
              import safetensors

              snake_case__						=				F"""{safetensors.__version__} but is ignored because of PyTorch version too old."""

          snake_case__						=				"not installed"
          snake_case__						=				snake_case__						=				"not found"
          if is_accelerate_available():
              import accelerate
              from accelerate.commands.config import default_config_file, load_config_from_file

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

              snake_case__						=				(
                  "\n".join([F"""\t- {prop}: {val}""" for prop, val in accelerate_config.items()] )
                  if isinstance(lowerCamelCase		,	lowerCamelCase )
                  else F"""\t{accelerate_config}"""
              )

          snake_case__						=				"not installed"
          snake_case__						=				"NA"
          if is_torch_available():
              import torch

              snake_case__						=				torch.__version__
              snake_case__						=				torch.cuda.is_available()

          snake_case__						=				"not installed"
          snake_case__						=				"NA"
          if is_tf_available():
              import tensorflow as tf

              snake_case__						=				tf.__version__
              try:
                  # deprecated in v2.1
                  snake_case__						=				tf.test.is_gpu_available()
              except AttributeError:
                  # returns list of devices, convert to bool
                  snake_case__						=				bool(tf.config.list_physical_devices("GPU" ) )

          snake_case__						=				"not installed"
          snake_case__						=				"not installed"
          snake_case__						=				"not installed"
          snake_case__						=				"NA"
          if is_flax_available():
              import flax
              import jax
              import jaxlib

              snake_case__						=				flax.__version__
              snake_case__						=				jax.__version__
              snake_case__						=				jaxlib.__version__
              snake_case__						=				jax.lib.xla_bridge.get_backend().platform

          snake_case__						=				{
              "`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(lowerCamelCase ) )

          return info



      @staticmethod
      def A_			(			lowerCamelCase ):
          return "\n".join([F"""- {prop}: {val}""" for prop, val in d.items()] ) + "\n"



