




"""simple docstring"""




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


lowerCAmelCase							:			Any     							=							logging.get_logger(__name__)

lowerCAmelCase							:			int     							=							{
    """google/mobilenet_v2_1.4_224""": """https://huggingface.co/google/mobilenet_v2_1.4_224/resolve/main/config.json""",
    """google/mobilenet_v2_1.0_224""": """https://huggingface.co/google/mobilenet_v2_1.0_224/resolve/main/config.json""",
    """google/mobilenet_v2_0.75_160""": """https://huggingface.co/google/mobilenet_v2_0.75_160/resolve/main/config.json""",
    """google/mobilenet_v2_0.35_96""": """https://huggingface.co/google/mobilenet_v2_0.35_96/resolve/main/config.json""",
    # See all MobileNetV2 models at https://huggingface.co/models?filter=mobilenet_v2
}






class     __magic_name__							(       UpperCAmelCase__				):






				'''simple docstring'''
				__UpperCamelCase			  =						"mobilenet_v2"





				def __init__(       self		, _a=3		, _a=224		, _a=1.0		, _a=8		, _a=8		, _a=6		, _a=32		, _a=True		, _a=True		, _a="relu6"		, _a=True		, _a=0.8		, _a=0.02		, _a=0.001		, _a=255		, **_a		, ):





							"""simple docstring"""
							super().__init__(**_a )

							if depth_multiplier <= 0:
										raise ValueError("""depth_multiplier must be greater than zero.""" )

							lowerCamelCase			      =					num_channels
							lowerCamelCase			      =					image_size
							lowerCamelCase			      =					depth_multiplier
							lowerCamelCase			      =					depth_divisible_by
							lowerCamelCase			      =					min_depth
							lowerCamelCase			      =					expand_ratio
							lowerCamelCase			      =					output_stride
							lowerCamelCase			      =					first_layer_is_expansion
							lowerCamelCase			      =					finegrained_output
							lowerCamelCase			      =					hidden_act
							lowerCamelCase			      =					tf_padding
							lowerCamelCase			      =					classifier_dropout_prob
							lowerCamelCase			      =					initializer_range
							lowerCamelCase			      =					layer_norm_eps
							lowerCamelCase			      =					semantic_loss_ignore_index






class     __magic_name__							(       UpperCAmelCase__				):






				'''simple docstring'''
				__UpperCamelCase			  =						version.parse("1.11"				)





				@property
				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							return OrderedDict([("""pixel_values""", {0: """batch"""})] )





				@property
				def    _lowerCAmelCase				(       self ):





							"""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    _lowerCAmelCase				(       self ):





							"""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     a__ (				)						->					Union[str, Any]:
			lowerCamelCase			      =					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=snake_case__       , default=1       , help="""Number of TPU cores to use (1 or 8)."""				)

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

			return parser.parse_args()



def     a__ (				)						->					List[str]:
			lowerCamelCase			      =					parse_args()

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

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



