





"""simple docstring"""




import functools
import operator

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


lowerCamelCase_	:		Optional[int]         =   logging.get_logger(__name__)

lowerCamelCase_	:		Optional[int]         =   {
    'facebook/hubert-base-ls960': 'https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json',
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}

class 					_UpperCAmelCase    (  UpperCAmelCase__						):



      '''simple docstring'''
      lowercase_ :					Optional[Any]             =  """hubert"""

      def __init__(	self   , snake_case_=3_2   , snake_case_=7_6_8   , snake_case_=1_2   , snake_case_=1_2   , snake_case_=3_0_7_2   , snake_case_="gelu"   , snake_case_=0.1   , snake_case_=0.1   , snake_case_=0.1   , snake_case_=True   , snake_case_=0.0   , snake_case_=0.1   , snake_case_=0.1   , snake_case_=0.02   , snake_case_=1E-5   , snake_case_="group"   , snake_case_="gelu"   , snake_case_=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)   , snake_case_=(5, 2, 2, 2, 2, 2, 2)   , snake_case_=(1_0, 3, 3, 3, 3, 2, 2)   , snake_case_=False   , snake_case_=1_2_8   , snake_case_=1_6   , snake_case_=False   , snake_case_=True   , snake_case_=0.05   , snake_case_=1_0   , snake_case_=2   , snake_case_=0.0   , snake_case_=1_0   , snake_case_=0   , snake_case_="sum"   , snake_case_=False   , snake_case_=False   , snake_case_=2_5_6   , snake_case_=0   , snake_case_=1   , snake_case_=2   , **snake_case_   , ):

        """simple docstring"""

        super().__init__(**snake_case_   , pad_token_id=snake_case_   , bos_token_id=snake_case_   , eos_token_id=snake_case_    )
        A_    :			Tuple									=    hidden_size
        A_    :			Union[str, Any]									=    feat_extract_norm
        A_    :			Union[str, Any]									=    feat_extract_activation
        A_    :			Tuple									=    list(snake_case_    )
        A_    :			List[str]									=    list(snake_case_    )
        A_    :			Union[str, Any]									=    list(snake_case_    )
        A_    :			Optional[int]									=    conv_bias
        A_    :			Any									=    num_conv_pos_embeddings
        A_    :			int									=    num_conv_pos_embedding_groups
        A_    :			Tuple									=    len(self.conv_dim    )
        A_    :			Union[str, Any]									=    num_hidden_layers
        A_    :			List[Any]									=    intermediate_size
        A_    :			str									=    hidden_act
        A_    :			int									=    num_attention_heads
        A_    :			str									=    hidden_dropout
        A_    :			List[Any]									=    attention_dropout
        A_    :			Any									=    activation_dropout
        A_    :			Optional[int]									=    feat_proj_layer_norm
        A_    :			str									=    feat_proj_dropout
        A_    :			Any									=    final_dropout
        A_    :			Dict									=    layerdrop
        A_    :			Any									=    layer_norm_eps
        A_    :			List[str]									=    initializer_range
        A_    :			Tuple									=    vocab_size
        A_    :			List[str]									=    do_stable_layer_norm
        A_    :			Optional[Any]									=    use_weighted_layer_sum
        A_    :			List[str]									=    classifier_proj_size

        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_    :			Union[str, Any]									=    apply_spec_augment
        A_    :			str									=    mask_time_prob
        A_    :			str									=    mask_time_length
        A_    :			Union[str, Any]									=    mask_time_min_masks
        A_    :			str									=    mask_feature_prob
        A_    :			int									=    mask_feature_length
        A_    :			List[str]									=    mask_feature_min_masks

        # ctc loss
        A_    :			Tuple									=    ctc_loss_reduction
        A_    :			int									=    ctc_zero_infinity

      @property
      def    lowerCamelCase_     (	self    ):

        """simple docstring"""

        return functools.reduce(operator.mul   , self.conv_stride   , 1    )
"""simple docstring"""







import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp




def 						_lowercase				(  )    ->     List[str]:







     '''simple docstring'''


     __A					:					int								=		ArgumentParser(
         description=(
             'PyTorch TPU distributed training launch helper utility that will spawn up multiple distributed processes'
         )						)

     # Optional arguments for the launch helper
     parser.add_argument('--num_cores'  ,       type=_SCREAMING_SNAKE_CASE  ,       default=1  ,       help='Number of TPU cores to use (1 or 8).'						)

     # positional
     parser.add_argument(
         'training_script'  ,       type=_SCREAMING_SNAKE_CASE  ,       help=(
             'The full path to the single TPU training '
             'program/script to be launched in parallel, '
             'followed by all the arguments for the '
             'training script'
         )  ,       )

     # rest from the training program
     parser.add_argument('training_script_args'  ,       nargs=_SCREAMING_SNAKE_CASE						)

     return parser.parse_args()




def 						_lowercase				(  )    ->     List[str]:







     '''simple docstring'''


     __A					:					List[str]								=		parse_args()

     # Import training_script as a module.
     __A					:					Dict								=		Path(args.training_script						)
     sys.path.append(str(script_fpath.parent.resolve()						)						)
     __A					:					List[Any]								=		script_fpath.stem
     __A					:					Optional[Any]								=		importlib.import_module(_SCREAMING_SNAKE_CASE						)

     # Patch sys.argv
     __A					:					Union[str, Any]								=		[args.training_script] + args.training_script_args + ['--tpu_num_cores', str(args.num_cores						)]

     xmp.spawn(mod._mp_fn  ,       args=()  ,       nprocs=args.num_cores						)


if __name__ == "__main__":
       main()



