'''simple docstring'''


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


__snake_case						  =		logging.get_logger(__name__)

__snake_case						  =		{
    """speechbrain/m-ctc-t-large""": """https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json""",
    # See all M-CTC-T models at https://huggingface.co/models?filter=mctct
}





class       _a    (		__a      ):


  """simple docstring"""

  A_    							=						'''mctct'''




  def __init__(		self      :       str   ,				lowercase_      :       Any=8_065   ,				lowercase_      :       Optional[int]=1_536   ,				lowercase_      :       Union[str, Any]=36   ,				lowercase_      :       int=6_144   ,				lowercase_      :       int=4   ,				lowercase_      :       Any=384   ,				lowercase_      :       Any=920   ,				lowercase_      :       List[str]=1e-5   ,				lowercase_      :       Union[str, Any]=0.3   ,				lowercase_      :       Tuple="relu"   ,				lowercase_      :       Any=0.0_2   ,				lowercase_      :       Any=0.3   ,				lowercase_      :       List[str]=0.3   ,				lowercase_      :       List[Any]=1   ,				lowercase_      :       Dict=0   ,				lowercase_      :       List[str]=2   ,				lowercase_      :       Tuple=1   ,				lowercase_      :       List[Any]=0.3   ,				lowercase_      :       Optional[int]=1   ,				lowercase_      :       Optional[int]=(7,)   ,				lowercase_      :       int=(3,)   ,				lowercase_      :       Optional[Any]=80   ,				lowercase_      :       int=1   ,				lowercase_      :       Union[str, Any]=None   ,				lowercase_      :       List[str]="sum"   ,				lowercase_      :       Optional[Any]=False   ,				**lowercase_      :       List[Any]   ,				):







    '''simple docstring'''


    super().__init__(**lowercase_   ,				pad_token_id=lowercase_   ,				bos_token_id=lowercase_   ,				eos_token_id=lowercase_      )
    lowercase_     =       vocab_size
    lowercase_     =       hidden_size
    lowercase_     =       num_hidden_layers
    lowercase_     =       intermediate_size
    lowercase_     =       num_attention_heads
    lowercase_     =       attention_head_dim
    lowercase_     =       max_position_embeddings
    lowercase_     =       layer_norm_eps
    lowercase_     =       layerdrop
    lowercase_     =       hidden_act
    lowercase_     =       initializer_range
    lowercase_     =       hidden_dropout_prob
    lowercase_     =       attention_probs_dropout_prob
    lowercase_     =       pad_token_id
    lowercase_     =       bos_token_id
    lowercase_     =       eos_token_id
    lowercase_     =       conv_glu_dim
    lowercase_     =       conv_dropout
    lowercase_     =       num_conv_layers
    lowercase_     =       input_feat_per_channel
    lowercase_     =       input_channels
    lowercase_     =       conv_channels
    lowercase_     =       ctc_loss_reduction
    lowercase_     =       ctc_zero_infinity

    # prevents config testing fail with exporting to json
    lowercase_     =       list(lowercase_      )
    lowercase_     =       list(lowercase_      )

    if len(self.conv_kernel      ) != self.num_conv_layers:
      raise ValueError(
          """Configuration for convolutional module is incorrect. """
          """It is required that `len(config.conv_kernel)` == `config.num_conv_layers` """
          F"""but is `len(config.conv_kernel) = {len(self.conv_kernel      )}`, """
          F"""`config.num_conv_layers = {self.num_conv_layers}`."""      )


'''simple docstring'''


from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
       import torch

if is_torch_tpu_available(check_device=False):
       import torch_xla.core.xla_model as xm


__snake_case						  =		logging.get_logger(__name__)





@dataclass
class       _a    (		__a      ):


  """simple docstring"""

  A_    							=						[
      '''no_inference''',
      '''no_cuda''',
      '''no_tpu''',
      '''no_speed''',
      '''no_memory''',
      '''no_env_print''',
      '''no_multi_process''',
  ]




  def __init__(		self      :       int   ,				**lowercase_      :       int      ):







    '''simple docstring'''


    for deprecated_arg in self.deprecated_args:
      if deprecated_arg in kwargs:
        lowercase_     =       deprecated_arg[3:]
        setattr(self   ,				lowercase_   ,				not kwargs.pop(lowercase_      )      )
        logger.warning(
            F"""{deprecated_arg} is depreciated. Please use --no_{positive_arg} or"""
            F""" {positive_arg}={kwargs[positive_arg]}"""      )

    lowercase_     =       kwargs.pop("""torchscript"""   ,				self.torchscript      )
    lowercase_     =       kwargs.pop("""torch_xla_tpu_print_metrics"""   ,				self.torch_xla_tpu_print_metrics      )
    lowercase_     =       kwargs.pop("""fp16_opt_level"""   ,				self.fpaa_opt_level      )
    super().__init__(**lowercase_      )

  A_    							=						field(default=__a ,				metadata={'''help''': '''Trace the models using torchscript'''}      )
  A_    							=						field(default=__a ,				metadata={'''help''': '''Print Xla/PyTorch tpu metrics'''}      )
  A_    							=						field(
      default='''O1''' ,				metadata={
          '''help''': (
              '''For fp16: Apex AMP optimization level selected in [\'O0\', \'O1\', \'O2\', and \'O3\']. '''
              '''See details at https://nvidia.github.io/apex/amp.html'''
          )
      } ,				)




  @cached_property
  def 		lowerCamelCase__  (		self      :       Dict      ):







    '''simple docstring'''


    requires_backends(self   ,				["""torch"""]      )
    logger.info("""PyTorch: setting up devices"""      )
    if not self.cuda:
      lowercase_     =       torch.device("""cpu"""      )
      lowercase_     =       0
    elif is_torch_tpu_available():
      lowercase_     =       xm.xla_device()
      lowercase_     =       0
    else:
      lowercase_     =       torch.device("""cuda""" if torch.cuda.is_available() else """cpu"""      )
      lowercase_     =       torch.cuda.device_count()
    return device, n_gpu




  @property
  def 		lowerCamelCase__  (		self      :       List[str]      ):







    '''simple docstring'''


    return is_torch_tpu_available() and self.tpu




  @property
  def 		lowerCamelCase__  (		self      :       Tuple      ):







    '''simple docstring'''


    requires_backends(self   ,				["""torch"""]      )
    # TODO(PVP): currently only single GPU is supported
    return torch.cuda.current_device()




  @property
  def 		lowerCamelCase__  (		self      :       Dict      ):







    '''simple docstring'''


    requires_backends(self   ,				["""torch"""]      )
    return self._setup_devices[0]




  @property
  def 		lowerCamelCase__  (		self      :       Any      ):







    '''simple docstring'''


    requires_backends(self   ,				["""torch"""]      )
    return self._setup_devices[1]





  @property
  def 		lowerCamelCase__  (		self      :       Optional[int]      ):







    '''simple docstring'''


    return self.n_gpu > 0

