






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


UpperCamelCase								=		logging.get_logger(__name__)

UpperCamelCase								=		{
    "facebook/data2vec-vision-base-ft": (
        "https://huggingface.co/facebook/data2vec-vision-base-ft/resolve/main/config.json"
    ),
}

class 				lowerCAmelCase_	(		__snake_case			):
				_UpperCamelCase					:       Optional[Any]							       = "data2vec-vision"


				def __init__(					self ,						_lowerCAmelCase=7_6_8 ,						_lowerCAmelCase=1_2 ,						_lowerCAmelCase=1_2 ,						_lowerCAmelCase=3_0_7_2 ,						_lowerCAmelCase="gelu" ,						_lowerCAmelCase=0.0 ,						_lowerCAmelCase=0.0 ,						_lowerCAmelCase=0.02 ,						_lowerCAmelCase=1E-12 ,						_lowerCAmelCase=2_2_4 ,						_lowerCAmelCase=1_6 ,						_lowerCAmelCase=3 ,						_lowerCAmelCase=False ,						_lowerCAmelCase=False ,						_lowerCAmelCase=False ,						_lowerCAmelCase=False ,						_lowerCAmelCase=0.1 ,						_lowerCAmelCase=0.1 ,						_lowerCAmelCase=True ,						_lowerCAmelCase=[3, 5, 7, 1_1] ,						_lowerCAmelCase=[1, 2, 3, 6] ,						_lowerCAmelCase=True ,						_lowerCAmelCase=0.4 ,						_lowerCAmelCase=2_5_6 ,						_lowerCAmelCase=1 ,						_lowerCAmelCase=False ,						_lowerCAmelCase=2_5_5 ,						**_lowerCAmelCase ,						):
											super().__init__(**_lowerCAmelCase      )

											_lowercase							:   int 							=   hidden_size
											_lowercase							:   Union[str, Any] 							=   num_hidden_layers
											_lowercase							:   List[Any] 							=   num_attention_heads
											_lowercase							:   Optional[Any] 							=   intermediate_size
											_lowercase							:   int 							=   hidden_act
											_lowercase							:   Optional[Any] 							=   hidden_dropout_prob
											_lowercase							:   List[str] 							=   attention_probs_dropout_prob
											_lowercase							:   Union[str, Any] 							=   initializer_range
											_lowercase							:   Dict 							=   layer_norm_eps

											_lowercase							:   int 							=   image_size
											_lowercase							:   List[str] 							=   patch_size
											_lowercase							:   Optional[int] 							=   num_channels
											_lowercase							:   Tuple 							=   use_mask_token
											_lowercase							:   Dict 							=   use_absolute_position_embeddings
											_lowercase							:   Union[str, Any] 							=   use_relative_position_bias
											_lowercase							:   List[Any] 							=   use_shared_relative_position_bias
											_lowercase							:   Tuple 							=   layer_scale_init_value
											_lowercase							:   Any 							=   drop_path_rate
											_lowercase							:   Tuple 							=   use_mean_pooling
											# decode head attributes (semantic segmentation)
											_lowercase							:   Dict 							=   out_indices
											_lowercase							:   int 							=   pool_scales
											# auxiliary head attributes (semantic segmentation)
											_lowercase							:   Tuple 							=   use_auxiliary_head
											_lowercase							:   str 							=   auxiliary_loss_weight
											_lowercase							:   Tuple 							=   auxiliary_channels
											_lowercase							:   Dict 							=   auxiliary_num_convs
											_lowercase							:   Optional[int] 							=   auxiliary_concat_input
											_lowercase							:   List[Any] 							=   semantic_loss_ignore_index




class 				lowerCAmelCase_	(		__snake_case			):
				_UpperCamelCase					:       int							       = version.parse("1.11"			)


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


				@property
				def 						__a					(					self      ):
											return 1E-4











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

import torch_xla.distributed.xla_multiprocessing as xmp





def  __magic_name__  (				)				-> str:

							"""simple docstring"""



							lowercase_	:   Optional[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=lowercase				,       default=1				,       help="""Number of TPU cores to use (1 or 8)."""				)

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

							return parser.parse_args()





def  __magic_name__  (				)				-> List[Any]:

							"""simple docstring"""



							lowercase_	:   Union[str, Any]  				=     parse_args()

							# Import training_script as a module.
							lowercase_	:   List[Any]  				=     Path(args.training_script				)
							sys.path.append(str(script_fpath.parent.resolve()				)				)
							lowercase_	:   Tuple  				=     script_fpath.stem
							lowercase_	:   List[str]  				=     importlib.import_module(lowercase				)

							# Patch sys.argv
							lowercase_	:   Optional[int]  				=     [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()