






'''simple docstring'''







# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


UpperCamelCase     :   Tuple	      =		[
    'EAGER',
    'AOT_EAGER',
    'INDUCTOR',
    'NVFUSER',
    'AOT_NVFUSER',
    'AOT_CUDAGRAPHS',
    'OFI',
    'FX2TRT',
    'ONNXRT',
    'IPEX',
]
def     A__      (					__lowerCAmelCase		:      Optional[int] ,     __lowerCAmelCase		:      Dict=None ,     __lowerCAmelCase		:      Any=None ,     __lowerCAmelCase		:      int=None    ):
						lowerCamelCase__								=	True
						while ask_again:
												lowerCamelCase__								=	input(__lowerCAmelCase    )
												try:
																		if default is not None and len(__lowerCAmelCase    ) == 0:
																								return default
																		return convert_value(__lowerCAmelCase    ) if convert_value is not None else result
												except Exception:
																		if error_message is not None:
																								print(__lowerCAmelCase    )
def     A__      (					__lowerCAmelCase		:      Any ,     __lowerCAmelCase		:      Optional[Any]=[] ,     __lowerCAmelCase		:      List[Any]=None ,     __lowerCAmelCase		:      Optional[int]=0    ):
						lowerCamelCase__								=	BulletMenu(__lowerCAmelCase ,     __lowerCAmelCase    )
						lowerCamelCase__								=	menu.run(default_choice=__lowerCAmelCase    )
						return convert_value(__lowerCAmelCase    ) if convert_value is not None else result
def     A__      (					__lowerCAmelCase		:      Union[str, Any]    ):
						lowerCamelCase__								=	int(__lowerCAmelCase    )
						return ComputeEnvironment(["""LOCAL_MACHINE""", """AMAZON_SAGEMAKER"""][value]    )
def     A__      (					__lowerCAmelCase		:      str    ):
						lowerCamelCase__								=	int(__lowerCAmelCase    )
						return DistributedType(["""NO""", """MULTI_CPU""", """MULTI_XPU""", """MULTI_GPU""", """MULTI_NPU""", """TPU"""][value]    )
def     A__      (					__lowerCAmelCase		:      str    ):
						lowerCamelCase__								=	int(__lowerCAmelCase    )
						return DynamoBackend(DYNAMO_BACKENDS[value]    ).value
def     A__      (					__lowerCAmelCase		:      Optional[Any]    ):
						lowerCamelCase__								=	int(__lowerCAmelCase    )
						return PrecisionType(["""no""", """fp16""", """bf16""", """fp8"""][value]    )
def     A__      (					__lowerCAmelCase		:      List[Any]    ):
						lowerCamelCase__								=	int(__lowerCAmelCase    )
						return SageMakerDistributedType(["""NO""", """DATA_PARALLEL""", """MODEL_PARALLEL"""][value]    )
def     A__      (					__lowerCAmelCase		:      Any    ):
						return {"yes": True, "no": False}[value.lower()]





class 		UpperCamelCase__     (argparse.RawDescriptionHelpFormatter      ):




		'''simple docstring'''





		def       UpperCamelCase_       (   self ,_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase							):
								lowerCamelCase__								=	super()._format_usage(_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase							)
								lowerCamelCase__								=	usage.replace("""<command> [<args>] """ ,""""""							)
								return usage







"""simple docstring"""

from collections import OrderedDict
from typing import Mapping

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


a							      =     logging.get_logger(__name__)

a							      =     {
    '''facebook/xmod-base''': '''https://huggingface.co/facebook/xmod-base/resolve/main/config.json''',
    '''facebook/xmod-large-prenorm''': '''https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json''',
    '''facebook/xmod-base-13-125k''': '''https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json''',
    '''facebook/xmod-base-30-125k''': '''https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json''',
    '''facebook/xmod-base-30-195k''': '''https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json''',
    '''facebook/xmod-base-60-125k''': '''https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json''',
    '''facebook/xmod-base-60-265k''': '''https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json''',
    '''facebook/xmod-base-75-125k''': '''https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json''',
    '''facebook/xmod-base-75-269k''': '''https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json''',
}





class 							lowercase_			(	__lowerCAmelCase				):



 '''simple docstring'''
 UpperCAmelCase       :	Optional[Any]     =      '''xmod'''

 def __init__(					self			:			str       ,				_UpperCAmelCase			:			Optional[Any]=30_522       ,				_UpperCAmelCase			:			Any=768       ,				_UpperCAmelCase			:			int=12       ,				_UpperCAmelCase			:			List[str]=12       ,				_UpperCAmelCase			:			Dict=3_072       ,				_UpperCAmelCase			:			Union[str, Any]="gelu"       ,				_UpperCAmelCase			:			Optional[int]=0.1       ,				_UpperCAmelCase			:			Tuple=0.1       ,				_UpperCAmelCase			:			List[str]=512       ,				_UpperCAmelCase			:			Dict=2       ,				_UpperCAmelCase			:			Optional[int]=0.02       ,				_UpperCAmelCase			:			Any=1E-1_2       ,				_UpperCAmelCase			:			Tuple=1       ,				_UpperCAmelCase			:			int=0       ,				_UpperCAmelCase			:			List[Any]=2       ,				_UpperCAmelCase			:			List[str]="absolute"       ,				_UpperCAmelCase			:			Tuple=True       ,				_UpperCAmelCase			:			Tuple=None       ,				_UpperCAmelCase			:			int=False       ,				_UpperCAmelCase			:			Union[str, Any]=2       ,				_UpperCAmelCase			:			List[Any]=False       ,				_UpperCAmelCase			:			Dict=True       ,				_UpperCAmelCase			:			List[str]=True       ,				_UpperCAmelCase			:			Tuple=("en_XX",)       ,				_UpperCAmelCase			:			List[str]=None       ,				**_UpperCAmelCase			:			Optional[Any]       ,				):
       super().__init__(pad_token_id=_UpperCAmelCase       ,				bos_token_id=_UpperCAmelCase       ,				eos_token_id=_UpperCAmelCase       ,				**_UpperCAmelCase						)

       _A     =  vocab_size
       _A     =  hidden_size
       _A     =  num_hidden_layers
       _A     =  num_attention_heads
       _A     =  hidden_act
       _A     =  intermediate_size
       _A     =  hidden_dropout_prob
       _A     =  attention_probs_dropout_prob
       _A     =  max_position_embeddings
       _A     =  type_vocab_size
       _A     =  initializer_range
       _A     =  layer_norm_eps
       _A     =  position_embedding_type
       _A     =  use_cache
       _A     =  classifier_dropout
       _A     =  pre_norm
       _A     =  adapter_reduction_factor
       _A     =  adapter_layer_norm
       _A     =  adapter_reuse_layer_norm
       _A     =  ln_before_adapter
       _A     =  list(_UpperCAmelCase						)
       _A     =  default_language





class 							lowercase_			(	__lowerCAmelCase				):



 '''simple docstring'''

 @property
 def      lowerCAmelCase_				(					self			:			Dict						):
       if self.task == "multiple-choice":
             _A     =  {0: 'batch', 1: 'choice', 2: 'sequence'}
       else:
             _A     =  {0: 'batch', 1: 'sequence'}
       return OrderedDict(
           [
               ('input_ids', dynamic_axis),
               ('attention_mask', dynamic_axis),
           ]						)

