
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase__				:				Dict						=      logging.get_logger(__name__)

lowercase__				:				Union[str, Any]						=      {
    "apple/mobilevitv2-1.0": "https://huggingface.co/apple/mobilevitv2-1.0/resolve/main/config.json",
}






class 							SCREAMING_SNAKE_CASE__     (				SCREAMING_SNAKE_CASE_     ):

							"""simple docstring"""






							_snake_case  		=	'mobilevitv2'



							def __init__(	self  ,						SCREAMING_SNAKE_CASE_=3  ,						SCREAMING_SNAKE_CASE_=256  ,						SCREAMING_SNAKE_CASE_=2  ,						SCREAMING_SNAKE_CASE_=2.0  ,						SCREAMING_SNAKE_CASE_="swish"  ,						SCREAMING_SNAKE_CASE_=3  ,						SCREAMING_SNAKE_CASE_=32  ,						SCREAMING_SNAKE_CASE_=0.1  ,						SCREAMING_SNAKE_CASE_=0.0_2  ,						SCREAMING_SNAKE_CASE_=1E-5  ,						SCREAMING_SNAKE_CASE_=512  ,						SCREAMING_SNAKE_CASE_=[6, 12, 18]  ,						SCREAMING_SNAKE_CASE_=0.1  ,						SCREAMING_SNAKE_CASE_=255  ,						SCREAMING_SNAKE_CASE_=[2, 4, 3]  ,						SCREAMING_SNAKE_CASE_=[128, 192, 256]  ,						SCREAMING_SNAKE_CASE_=1.0  ,						SCREAMING_SNAKE_CASE_=2  ,						SCREAMING_SNAKE_CASE_=0.0  ,						SCREAMING_SNAKE_CASE_=0.0  ,						**SCREAMING_SNAKE_CASE_  ,						)-> Optional[int]:





													'''simple docstring'''






													super().__init__(**SCREAMING_SNAKE_CASE_      )

													__UpperCamelCase  	=      num_channels
													__UpperCamelCase  	=      image_size
													__UpperCamelCase  	=      patch_size
													__UpperCamelCase  	=      expand_ratio
													__UpperCamelCase  	=      hidden_act
													__UpperCamelCase  	=      conv_kernel_size
													__UpperCamelCase  	=      output_stride
													__UpperCamelCase  	=      initializer_range
													__UpperCamelCase  	=      layer_norm_eps
													__UpperCamelCase  	=      n_attn_blocks
													__UpperCamelCase  	=      base_attn_unit_dims
													__UpperCamelCase  	=      width_multiplier
													__UpperCamelCase  	=      ffn_multiplier
													__UpperCamelCase  	=      ffn_dropout
													__UpperCamelCase  	=      attn_dropout
													__UpperCamelCase  	=      classifier_dropout_prob

													# decode head attributes for semantic segmentation
													__UpperCamelCase  	=      aspp_out_channels
													__UpperCamelCase  	=      atrous_rates
													__UpperCamelCase  	=      aspp_dropout_prob
													__UpperCamelCase  	=      semantic_loss_ignore_index






class 							SCREAMING_SNAKE_CASE__     (				SCREAMING_SNAKE_CASE_     ):

							"""simple docstring"""






							_snake_case  		=	version.parse('1.11'     )



							@property
							def      A__		(	self      )-> Mapping[str, Mapping[int, str]]:





													'''simple docstring'''






													return OrderedDict([('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''})]      )



							@property
							def      A__		(	self      )-> Mapping[str, Mapping[int, str]]:





													'''simple docstring'''






													if self.task == "image-classification":
																			return OrderedDict([('''logits''', {0: '''batch'''})]      )
													else:
																			return OrderedDict([('''last_hidden_state''', {0: '''batch'''}), ('''pooler_output''', {0: '''batch'''})]      )



							@property
							def      A__		(	self      )-> float:





													'''simple docstring'''






													return 1E-4





"""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()



