



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


A__  :  int								=					logging.get_logger(__name__)

A__  :  Optional[int]								=					{
    '''facebook/data2vec-vision-base-ft''': (
        '''https://huggingface.co/facebook/data2vec-vision-base-ft/resolve/main/config.json'''
    ),
}



class 				__snake_case						(     UpperCamelCase_						):
							_a			      = '''data2vec-vision'''




							def __init__(       self     :       Tuple				,				A_     :       List[Any]=7_6_8				,				A_     :       Union[str, Any]=1_2				,				A_     :       Dict=1_2				,				A_     :       List[Any]=3_0_7_2				,				A_     :       Dict="gelu"				,				A_     :       Tuple=0.0				,				A_     :       Dict=0.0				,				A_     :       List[str]=0.02				,				A_     :       List[str]=1e-12				,				A_     :       Tuple=2_2_4				,				A_     :       Dict=1_6				,				A_     :       Optional[int]=3				,				A_     :       Optional[int]=False				,				A_     :       Any=False				,				A_     :       Tuple=False				,				A_     :       Optional[int]=False				,				A_     :       int=0.1				,				A_     :       Union[str, Any]=0.1				,				A_     :       List[Any]=True				,				A_     :       List[Any]=[3, 5, 7, 1_1]				,				A_     :       Union[str, Any]=[1, 2, 3, 6]				,				A_     :       Optional[int]=True				,				A_     :       Any=0.4				,				A_     :       str=2_5_6				,				A_     :       Optional[int]=1				,				A_     :       str=False				,				A_     :       Optional[int]=2_5_5				,				**A_     :       Optional[int]				,				):
									super().__init__(**A_)

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

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





class 				__snake_case						(     UpperCamelCase_						):
							_a			      = version.parse('''1.11'''						)




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







							@property
							def    UpperCAmelCase__			(       self     :       Dict):
									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 			UpperCamelCase(  ):
		lowerCAmelCase_			:     List[str]									= 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=__UpperCamelCase     ,default=1     ,help='''Number of TPU cores to use (1 or 8).''' )

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

		return parser.parse_args()


def 			UpperCamelCase(  ):
		lowerCAmelCase_			:     str									= parse_args()

		# Import training_script as a module.
		lowerCAmelCase_			:     str									= Path(args.training_script )
		sys.path.append(str(script_fpath.parent.resolve() ) )
		lowerCAmelCase_			:     Tuple									= script_fpath.stem
		lowerCAmelCase_			:     Union[str, Any]									= importlib.import_module(__UpperCamelCase )

		# Patch sys.argv
		lowerCAmelCase_			:     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()





