





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

import torch_xla.distributed.xla_multiprocessing as xmp





def 						__SCREAMING_SNAKE_CASE  (    )  ->    Any:







   '''simple docstring'''

   UpperCAmelCase       		=    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=__A      ,      default=1      ,      help='''Number of TPU cores to use (1 or 8).'''			)

   # positional
   parser.add_argument(
       '''training_script'''      ,      type=__A      ,      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=__A			)

   return parser.parse_args()





def 						__SCREAMING_SNAKE_CASE  (    )  ->    Union[str, Any]:







   '''simple docstring'''

   UpperCAmelCase       		=    parse_args()

   # Import training_script as a module.
   UpperCAmelCase       		=    Path(args.training_script			)
   sys.path.append(str(script_fpath.parent.resolve()			)			)
   UpperCAmelCase       		=    script_fpath.stem
   UpperCAmelCase       		=    importlib.import_module(__A			)

   # Patch sys.argv
   UpperCAmelCase       		=    [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()










import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


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

class      A_	(a_      ):
	UpperCAmelCase__ =      '''speech-encoder-decoder'''
	UpperCAmelCase__ =      True
	def __init__(   self							, **_A		):






				'''simple docstring'''







				super().__init__(**_A		)
				if "encoder" not in kwargs or "decoder" not in kwargs:
							raise ValueError(
							    F"""A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and"""
							    F""" `decoder` sub-configurations are passed, but only {kwargs}"""		)

				UpperCAmelCase       		=    kwargs.pop('''encoder'''		)
				UpperCAmelCase       		=    encoder_config.pop('''model_type'''		)
				UpperCAmelCase       		=    kwargs.pop('''decoder'''		)
				UpperCAmelCase       		=    decoder_config.pop('''model_type'''		)

				UpperCAmelCase       		=    AutoConfig.for_model(_A							, **_A		)
				UpperCAmelCase       		=    AutoConfig.for_model(_A							, **_A		)
				UpperCAmelCase       		=    True
	@classmethod
	def 					_lowercase    (   cls							, _A							, _A							, **_A		):






				'''simple docstring'''







				logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'''		)
				UpperCAmelCase       		=    True
				UpperCAmelCase       		=    True

				return cls(encoder=encoder_config.to_dict()							, decoder=decoder_config.to_dict()							, **_A		)







	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    copy.deepcopy(self.__dict__		)
				UpperCAmelCase       		=    self.encoder.to_dict()
				UpperCAmelCase       		=    self.decoder.to_dict()
				UpperCAmelCase       		=    self.__class__.model_type
				return output



