# 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


lowerCAmelCase__     						=			[
    'EAGER',
    'AOT_EAGER',
    'INDUCTOR',
    'NVFUSER',
    'AOT_NVFUSER',
    'AOT_CUDAGRAPHS',
    'OFI',
    'FX2TRT',
    'ONNXRT',
    'IPEX',
]






def 				__lowerCamelCase		(						lowerCAmelCase__     ,  lowerCAmelCase__=None     ,  lowerCAmelCase__=None     ,  lowerCAmelCase__=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 				__lowerCamelCase		(						lowerCAmelCase__     ,  lowerCAmelCase__=[]     ,  lowerCAmelCase__=None     ,  lowerCAmelCase__=0     ):
       lowerCAmelCase__					     = BulletMenu(lowerCAmelCase__     ,  lowerCAmelCase__     )
       lowerCAmelCase__					     = menu.run(default_choice=lowerCAmelCase__     )
       return convert_value(lowerCAmelCase__     ) if convert_value is not None else result






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       lowerCAmelCase__					     = int(lowerCAmelCase__     )
       return ComputeEnvironment(['LOCAL_MACHINE', 'AMAZON_SAGEMAKER'][value]     )






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       lowerCAmelCase__					     = int(lowerCAmelCase__     )
       return DistributedType(['NO', 'MULTI_CPU', 'MULTI_XPU', 'MULTI_GPU', 'MULTI_NPU', 'TPU'][value]     )






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       lowerCAmelCase__					     = int(lowerCAmelCase__     )
       return DynamoBackend(DYNAMO_BACKENDS[value]     ).value






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       lowerCAmelCase__					     = int(lowerCAmelCase__     )
       return PrecisionType(['no', 'fp16', 'bf16', 'fp8'][value]     )






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       lowerCAmelCase__					     = int(lowerCAmelCase__     )
       return SageMakerDistributedType(['NO', 'DATA_PARALLEL', 'MODEL_PARALLEL'][value]     )






def 				__lowerCamelCase		(						lowerCAmelCase__     ):
       return {"yes": True, "no": False}[value.lower()]



class     a_			(						argparse.RawDescriptionHelpFormatter						):






 '''simple docstring'''






 def 		__snake_case						(      self :  List[Any]      ,   lowercase__ :  List[Any]      ,   lowercase__ :  Union[str, Any]      ,   lowercase__ :  Optional[Any]      ,   lowercase__ :  List[str]):







        '''simple docstring'''



        lowerCAmelCase__					     = super()._format_usage(lowercase__      ,   lowercase__      ,   lowercase__      ,   lowercase__)
        lowerCAmelCase__					     = usage.replace('<command> [<args>] '      ,   '')
        return usage

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


lowerCAmelCase__     						=			{
    'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'],
    'tokenization_transfo_xl': ['TransfoXLCorpus', 'TransfoXLTokenizer'],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase__     						=			[
        'TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
        'AdaptiveEmbedding',
        'TransfoXLForSequenceClassification',
        'TransfoXLLMHeadModel',
        'TransfoXLModel',
        'TransfoXLPreTrainedModel',
        'load_tf_weights_in_transfo_xl',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase__     						=			[
        'TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
        'TFAdaptiveEmbedding',
        'TFTransfoXLForSequenceClassification',
        'TFTransfoXLLMHeadModel',
        'TFTransfoXLMainLayer',
        'TFTransfoXLModel',
        'TFTransfoXLPreTrainedModel',
    ]


if TYPE_CHECKING:
    from .configuration_transfo_xl import TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, TransfoXLConfig
    from .tokenization_transfo_xl import TransfoXLCorpus, TransfoXLTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_transfo_xl import (
            TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
            AdaptiveEmbedding,
            TransfoXLForSequenceClassification,
            TransfoXLLMHeadModel,
            TransfoXLModel,
            TransfoXLPreTrainedModel,
            load_tf_weights_in_transfo_xl,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_transfo_xl import (
            TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFAdaptiveEmbedding,
            TFTransfoXLForSequenceClassification,
            TFTransfoXLLMHeadModel,
            TFTransfoXLMainLayer,
            TFTransfoXLModel,
            TFTransfoXLPreTrainedModel,
        )

else:
    import sys

    lowerCAmelCase__     						=			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
