

"""simple docstring"""





import unittest
from dataclasses import dataclass

import pytest

from accelerate.commands.config.config_args import SageMakerConfig
from accelerate.utils import ComputeEnvironment
from accelerate.utils.launch import _convert_nargs_to_dict







@dataclass
class 				SCREAMING_SNAKE_CASE					(		a_       ):






					"""simple docstring"""



					lowercase__				 =       ComputeEnvironment.AMAZON_SAGEMAKER
					lowercase__				 =       True
					lowercase__				 =       "ml.p3.2xlarge"
					lowercase__				 =       "accelerate_sagemaker_execution_role"
					lowercase__				 =       "hf-sm"
					lowercase__				 =       "us-east-1"
					lowercase__				 =       1
					lowercase__				 =       "accelerate-sagemaker-1"
					lowercase__				 =       "1.6"
					lowercase__				 =       "4.4"
					lowercase__				 =       "train.py"
					lowercase__				 =       [
					    "--model_name_or_path",
					    "bert",
					    "--do_train",
					    "False",
					    "--epochs",
					    "3",
					    "--learning_rate",
					    "5e-5",
					    "--max_steps",
					    "50.5",
					]
					lowercase__				 =       [
					    "--model_name_or_path",
					    "bert",
					    "--do_train",
					    "--do_test",
					    "False",
					    "--do_predict",
					    "--epochs",
					    "3",
					    "--learning_rate",
					    "5e-5",
					    "--max_steps",
					    "50.5",
					]







class 				SCREAMING_SNAKE_CASE					(		unittest.TestCase       ):






					"""simple docstring"""



					def        __lowerCAmelCase (       self			:				Optional[int]		):
						# If no defaults are changed, `to_kwargs` returns an empty dict.
						lowerCAmelCase__	:						Tuple  				=	_convert_nargs_to_dict(MockLaunchConfig.success_training_script_args		)
						assert isinstance(converted_args['''model_name_or_path''']   ,lowercase_		)
						assert isinstance(converted_args['''do_train''']   ,lowercase_		)
						assert isinstance(converted_args['''epochs''']   ,lowercase_		)
						assert isinstance(converted_args['''learning_rate''']   ,lowercase_		)
						assert isinstance(converted_args['''max_steps''']   ,lowercase_		)

						with pytest.raises(lowercase_		):
							_convert_nargs_to_dict(MockLaunchConfig.fail_training_script_args		)







"""simple docstring"""





from ..utils import DummyObject, requires_backends







class 				SCREAMING_SNAKE_CASE					(		metaclass=a_       ):






					"""simple docstring"""



					lowercase__				 =       ["speech"]







					def __init__(       self			:				Tuple   ,*lowercase_			:				Tuple   ,**lowercase_			:				List[str]		):
						requires_backends(self   ,['''speech''']		)







class 				SCREAMING_SNAKE_CASE					(		metaclass=a_       ):






					"""simple docstring"""



					lowercase__				 =       ["speech"]







					def __init__(       self			:				Union[str, Any]   ,*lowercase_			:				List[str]   ,**lowercase_			:				Any		):
						requires_backends(self   ,['''speech''']		)




