from argparse import ArgumentParser

from . import BaseTransformersCLICommand




def       lowerCAmelCase_     (		lowercase:							Dict		)    ->				Union[str, Any]:







 '''simple docstring'''
 return DownloadCommand(args.model  ,					args.cache_dir  ,					args.force  ,					args.trust_remote_code		)





class  __magic_name__  (		__a    ):





   """simple docstring"""




   @staticmethod
   def   lowerCAmelCase						(	_lowercase					:  ArgumentParser							):



    """simple docstring"""



    _UpperCamelCase:     Optional[Any]							= parser.add_parser('''download'''							)
    download_parser.add_argument(
        '''--cache-dir'''		,  type=_lowercase		,  default=_lowercase		,  help='''Path to location to store the models'''							)
    download_parser.add_argument(
        '''--force'''		,  action='''store_true'''		,  help='''Force the model to be download even if already in cache-dir'''							)
    download_parser.add_argument(
        '''--trust-remote-code'''		,  action='''store_true'''		,  help='''Whether or not to allow for custom models defined on the Hub in their own modeling files. Use only if you\'ve reviewed the code as it will execute on your local machine'''		,  )
    download_parser.add_argument('''model'''		,  type=_lowercase		,  help='''Name of the model to download'''							)
    download_parser.set_defaults(func=_lowercase							)



   def __init__(	self					:  Tuple		,  _lowercase					:  str		,  _lowercase					:  str		,  _lowercase					:  bool		,  _lowercase					:  bool							):



    """simple docstring"""



    _UpperCamelCase:     Any							= model
    _UpperCamelCase:     List[str]							= cache
    _UpperCamelCase:     Optional[int]							= force
    _UpperCamelCase:     Tuple							= trust_remote_code



   def   lowerCAmelCase						(	self					:  Tuple							):



    """simple docstring"""



    from ..models.auto import AutoModel, AutoTokenizer

    AutoModel.from_pretrained(
        self._model		,  cache_dir=self._cache		,  force_download=self._force		,  trust_remote_code=self._trust_remote_code							)
    AutoTokenizer.from_pretrained(
        self._model		,  cache_dir=self._cache		,  force_download=self._force		,  trust_remote_code=self._trust_remote_code							)
# 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_			    =							[
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]




def       lowerCAmelCase_     (		lowercase:							str  ,					lowercase:							Optional[Any]=None  ,					lowercase:							List[str]=None  ,					lowercase:							List[str]=None		)    ->				Tuple:







 '''simple docstring'''
 _UpperCamelCase:     int							= True
 while ask_again:
  _UpperCamelCase:     Any							= input(lowercase		)
  try:
   if default is not None and len(lowercase		) == 0:
    return default
   return convert_value(lowercase		) if convert_value is not None else result
  except Exception:
   if error_message is not None:
    print(lowercase		)




def       lowerCAmelCase_     (		lowercase:							List[Any]  ,					lowercase:							Union[str, Any]=[]  ,					lowercase:							Union[str, Any]=None  ,					lowercase:							Union[str, Any]=0		)    ->				List[Any]:







 '''simple docstring'''
 _UpperCamelCase:     List[str]							= BulletMenu(lowercase  ,					lowercase		)
 _UpperCamelCase:     List[Any]							= menu.run(default_choice=lowercase		)
 return convert_value(lowercase		) if convert_value is not None else result




def       lowerCAmelCase_     (		lowercase:							Dict		)    ->				Optional[int]:







 '''simple docstring'''
 _UpperCamelCase:     int							= int(lowercase		)
 return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]		)




def       lowerCAmelCase_     (		lowercase:							Tuple		)    ->				Any:







 '''simple docstring'''
 _UpperCamelCase:     str							= int(lowercase		)
 return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]		)




def       lowerCAmelCase_     (		lowercase:							Union[str, Any]		)    ->				Optional[int]:







 '''simple docstring'''
 _UpperCamelCase:     Tuple							= int(lowercase		)
 return DynamoBackend(DYNAMO_BACKENDS[value]		).value




def       lowerCAmelCase_     (		lowercase:							int		)    ->				Any:







 '''simple docstring'''
 _UpperCamelCase:     int							= int(lowercase		)
 return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]		)




def       lowerCAmelCase_     (		lowercase:							List[str]		)    ->				List[str]:







 '''simple docstring'''
 _UpperCamelCase:     Dict							= int(lowercase		)
 return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]		)




def       lowerCAmelCase_     (		lowercase:							Any		)    ->				List[str]:







 '''simple docstring'''
 return {"yes": True, "no": False}[value.lower()]





class  __magic_name__  (		argparse.RawDescriptionHelpFormatter    ):





   """simple docstring"""




   def   lowerCAmelCase						(	self					:  str		,  _lowercase					:  Optional[int]		,  _lowercase					:  List[Any]		,  _lowercase					:  Dict		,  _lowercase					:  Any							):



    """simple docstring"""



    _UpperCamelCase:     Optional[Any]							= super()._format_usage(_lowercase		,  _lowercase		,  _lowercase		,  _lowercase							)
    _UpperCamelCase:     int							= usage.replace('''<command> [<args>] '''		,  ''''''							)
    return usage