
"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCAmelCase       =  logging.get_logger(__name__)

__UpperCAmelCase       =  {
    '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''',
    '''tiiuae/falcon-7b''': '''https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json''',
}




class 			_SCREAMING_SNAKE_CASE					(			a__							):
			UpperCAmelCase_  :Optional[int]				 =						"""falcon"""
			UpperCAmelCase_  :Union[str, Any]				 =						["""past_key_values"""]






			def __init__(					self       ,   __A=6_5024       ,   __A=4544       ,   __A=32       ,   __A=71       ,   __A=1E-5       ,   __A=0.0_2       ,   __A=True       ,   __A=0.0       ,   __A=0.0       ,   __A=None       ,   __A=False       ,   __A=False       ,   __A=True       ,   __A=True       ,   __A=False       ,   __A=11       ,   __A=11       ,   **__A       ,   )			->     Any:
						lowerCAmelCase_    :Optional[int]			     =  vocab_size
						# Backward compatibility with n_embed kwarg
						lowerCAmelCase_    :Tuple			     =  kwargs.pop("""n_embed"""       ,   lowerCAmelCase__       )
						lowerCAmelCase_    :int			     =  hidden_size if n_embed is None else n_embed
						lowerCAmelCase_    :Dict			     =  num_hidden_layers
						lowerCAmelCase_    :Any			     =  num_attention_heads
						lowerCAmelCase_    :List[str]			     =  layer_norm_epsilon
						lowerCAmelCase_    :Any			     =  initializer_range
						lowerCAmelCase_    :Dict			     =  use_cache
						lowerCAmelCase_    :Optional[int]			     =  hidden_dropout
						lowerCAmelCase_    :Optional[int]			     =  attention_dropout

						lowerCAmelCase_    :Optional[int]			     =  bos_token_id
						lowerCAmelCase_    :List[Any]			     =  eos_token_id
						lowerCAmelCase_    :str			     =  num_attention_heads if num_kv_heads is None else num_kv_heads
						lowerCAmelCase_    :Union[str, Any]			     =  alibi
						lowerCAmelCase_    :Any			     =  new_decoder_architecture
						lowerCAmelCase_    :Dict			     =  multi_query  # Ignored when new_decoder_architecture is True
						lowerCAmelCase_    :List[Any]			     =  parallel_attn
						lowerCAmelCase_    :List[str]			     =  bias

						super().__init__(bos_token_id=lowerCAmelCase__       ,   eos_token_id=lowerCAmelCase__       ,   **lowerCAmelCase__       )






			@property
			def  __lowerCAmelCase (					self       )			->     Optional[int]:
						return self.hidden_size // self.num_attention_heads






			@property
			def  __lowerCAmelCase (					self       )			->     Dict:
						return not self.alibi













"""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        __UpperCamelCase				(						a__						):
							lowerCamelCase   :					List[str]      					=ComputeEnvironment.AMAZON_SAGEMAKER
							lowerCamelCase   :					str      					=True
							lowerCamelCase   :					Union[str, Any]      					="""ml.p3.2xlarge"""
							lowerCamelCase   :					str      					="""accelerate_sagemaker_execution_role"""
							lowerCamelCase   :					int      					="""hf-sm"""
							lowerCamelCase   :					int      					="""us-east-1"""
							lowerCamelCase   :					Tuple      					=1
							lowerCamelCase   :					Any      					="""accelerate-sagemaker-1"""
							lowerCamelCase   :					str      					="""1.6"""
							lowerCamelCase   :					Tuple      					="""4.4"""
							lowerCamelCase   :					Optional[int]      					="""train.py"""
							lowerCamelCase   :					Optional[Any]      					=[
							    """--model_name_or_path""",
							    """bert""",
							    """--do_train""",
							    """False""",
							    """--epochs""",
							    """3""",
							    """--learning_rate""",
							    """5e-5""",
							    """--max_steps""",
							    """50.5""",
							]
							lowerCamelCase   :					Union[str, Any]      					=[
							    """--model_name_or_path""",
							    """bert""",
							    """--do_train""",
							    """--do_test""",
							    """False""",
							    """--do_predict""",
							    """--epochs""",
							    """3""",
							    """--learning_rate""",
							    """5e-5""",
							    """--max_steps""",
							    """50.5""",
							]


class        __UpperCamelCase				(						unittest.TestCase						):






							def     __a   (   self      )	-> List[str]:
								# If no defaults are changed, `to_kwargs` returns an empty dict.
								a      :		str	=				_convert_nargs_to_dict(MockLaunchConfig.success_training_script_args      )
								assert isinstance(converted_args["model_name_or_path"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["do_train"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["epochs"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["learning_rate"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["max_steps"]      ,					lowerCAmelCase__      )

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


