






import argparse
import os

from accelerate.utils import ComputeEnvironment

from .cluster import get_cluster_input
from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file  # noqa: F401
from .config_utils import _ask_field, _ask_options, _convert_compute_environment  # noqa: F401
from .sagemaker import get_sagemaker_input


__a       :	Optional[int]             = """Launches a series of prompts to create and save a `default_config.yaml` configuration file for your training system. Should always be ran first on your machine"""





def        SCREAMING_SNAKE_CASE       (      ):
					a__          =  _ask_options(
					    '''In which compute environment are you running?''' ,     ['''This machine''', '''AWS (Amazon SageMaker)'''] ,     _convert_compute_environment ,     )
					if compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
										a__          =  get_sagemaker_input()
					else:
										a__          =  get_cluster_input()
					return config





def        SCREAMING_SNAKE_CASE       (      lowerCamelCase_=None):







					if subparsers is not None:
										a__          =  subparsers.add_parser('''config''' ,     description=lowerCamelCase_)
					else:
										a__          =  argparse.ArgumentParser('''Accelerate config command''' ,     description=lowerCamelCase_)

					parser.add_argument(
					    '''--config_file''' ,     default=lowerCamelCase_ ,     help=(
					        '''The path to use to store the config file. Will default to a file named default_config.yaml in the cache '''
					        '''location, which is the content of the environment `HF_HOME` suffixed with \'accelerate\', or if you don\'t have '''
					        '''such an environment variable, your cache directory (\'~/.cache\' or the content of `XDG_CACHE_HOME`) suffixed '''
					        '''with \'huggingface\'.'''
					    ) ,     )

					if subparsers is not None:
										parser.set_defaults(func=lowerCamelCase_)
					return parser





def        SCREAMING_SNAKE_CASE       (      lowerCamelCase_):
					a__          =  get_user_input()
					if args.config_file is not None:
										a__          =  args.config_file
					else:
										if not os.path.isdir(lowerCamelCase_):
															os.makedirs(lowerCamelCase_)
										a__          =  default_yaml_config_file

					if config_file.endswith('''.json'''):
										config.to_json_file(lowerCamelCase_)
					else:
										config.to_yaml_file(lowerCamelCase_)
					print(f'accelerate configuration saved at {config_file}')





def        SCREAMING_SNAKE_CASE       (      ):
					a__          =  config_command_parser()
					a__          =  parser.parse_args()
					config_command(lowerCamelCase_)


if __name__ == "__main__":
	main()










"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__a       :	Tuple             = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfig', 'DeiTOnnxConfig']}

try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__a       :	Tuple             = ['DeiTFeatureExtractor']
	__a       :	Optional[Any]             = ['DeiTImageProcessor']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__a       :	Optional[int]             = [
	    'DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'DeiTForImageClassification',
	    'DeiTForImageClassificationWithTeacher',
	    'DeiTForMaskedImageModeling',
	    'DeiTModel',
	    'DeiTPreTrainedModel',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__a       :	Dict             = [
	    'TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'TFDeiTForImageClassification',
	    'TFDeiTForImageClassificationWithTeacher',
	    'TFDeiTForMaskedImageModeling',
	    'TFDeiTModel',
	    'TFDeiTPreTrainedModel',
	]


if TYPE_CHECKING:
	from .configuration_deit import DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, DeiTConfig, DeiTOnnxConfig

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .feature_extraction_deit import DeiTFeatureExtractor
		from .image_processing_deit import DeiTImageProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_deit import (
		    DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DeiTForImageClassification,
		    DeiTForImageClassificationWithTeacher,
		    DeiTForMaskedImageModeling,
		    DeiTModel,
		    DeiTPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_deit import (
		    TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFDeiTForImageClassification,
		    TFDeiTForImageClassificationWithTeacher,
		    TFDeiTForMaskedImageModeling,
		    TFDeiTModel,
		    TFDeiTPreTrainedModel,
		)


else:
	import sys

	__a       :	List[Any]             = _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


