

from .integrations import (
    is_optuna_available,
    is_ray_available,
    is_sigopt_available,
    is_wandb_available,
    run_hp_search_optuna,
    run_hp_search_ray,
    run_hp_search_sigopt,
    run_hp_search_wandb,
)
from .trainer_utils import (
    HPSearchBackend,
    default_hp_space_optuna,
    default_hp_space_ray,
    default_hp_space_sigopt,
    default_hp_space_wandb,
)
from .utils import logging


A_	:			List[Any]  	=      logging.get_logger(__name__)



class    _a						:


					'''simple docstring'''






					UpperCAmelCase__:       str
					UpperCAmelCase__:       str  							=	None






					@staticmethod
					def   __A      (			):
						raise NotImplementedError






					def   __A      (			self   ,	A__   ,	A__   ,	A__   ,	**A__      ):
						raise NotImplementedError






					def   __A      (			self   ,	A__      ):
						raise NotImplementedError






					def   __A      (			self      ):
						if not self.is_available():
							raise RuntimeError(
							    F"""You picked the {self.name} backend, but it is not installed. Run {self.pip_install()}."""      )






					@classmethod
					def   __A      (			cls      ):
						return F"""`pip install {cls.pip_package or cls.name}`"""



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Optional[Any]  							=	'''optuna'''






					@staticmethod
					def   __A      (			):
						return is_optuna_available()






					def   __A      (			self   ,	A__   ,	A__   ,	A__   ,	**A__      ):
						return run_hp_search_optuna(A__   ,	A__   ,	A__   ,	**A__      )






					def   __A      (			self   ,	A__      ):
						return default_hp_space_optuna(A__      )



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       str  							=	'''ray'''
					UpperCAmelCase__:       Optional[Any]  							=	'''\'ray[tune]\''''






					@staticmethod
					def   __A      (			):
						return is_ray_available()






					def   __A      (			self   ,	A__   ,	A__   ,	A__   ,	**A__      ):
						return run_hp_search_ray(A__   ,	A__   ,	A__   ,	**A__      )






					def   __A      (			self   ,	A__      ):
						return default_hp_space_ray(A__      )



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Optional[int]  							=	'''sigopt'''






					@staticmethod
					def   __A      (			):
						return is_sigopt_available()






					def   __A      (			self   ,	A__   ,	A__   ,	A__   ,	**A__      ):
						return run_hp_search_sigopt(A__   ,	A__   ,	A__   ,	**A__      )






					def   __A      (			self   ,	A__      ):
						return default_hp_space_sigopt(A__      )



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       str  							=	'''wandb'''






					@staticmethod
					def   __A      (			):
						return is_wandb_available()






					def   __A      (			self   ,	A__   ,	A__   ,	A__   ,	**A__      ):
						return run_hp_search_wandb(A__   ,	A__   ,	A__   ,	**A__      )






					def   __A      (			self   ,	A__      ):
						return default_hp_space_wandb(A__      )



A_	:			Optional[int]  	=      {
    HPSearchBackend(backend.name): backend for backend in [OptunaBackend, RayTuneBackend, SigOptBackend, WandbBackend]
}

def 						UpperCamelCase ()					->				str:
	A__							:   Optional[Any]					       =		[backend for backend in ALL_HYPERPARAMETER_SEARCH_BACKENDS.values() if backend.is_available()]
	if len(lowercase_ ) > 0:
		A__							:   Union[str, Any]					       =		available_backends[0].name
		if len(lowercase_ ) > 1:
			logger.info(
			    f"""{len(lowercase_ )} hyperparameter search backends available. Using {name} as the default.""" )
		return name
	raise RuntimeError(
	    """No hyperparameter search backend available.\n"""
	    + """\n""".join(
	        f""" - To install {backend.name} run {backend.pip_install()}"""
	        for backend in ALL_HYPERPARAMETER_SEARCH_BACKENDS.values() ) )






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


A_	:			str  	=      logging.get_logger(__name__)

A_	:			Any  	=      {
    '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    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Dict  							=	'''falcon'''
					UpperCAmelCase__:       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__   ,	):
						A__							:   Dict					       =		vocab_size
						# Backward compatibility with n_embed kwarg
						A__							:   Union[str, Any]					       =		kwargs.pop("""n_embed"""   ,	A__      )
						A__							:   Optional[Any]					       =		hidden_size if n_embed is None else n_embed
						A__							:   Any					       =		num_hidden_layers
						A__							:   Any					       =		num_attention_heads
						A__							:   Optional[Any]					       =		layer_norm_epsilon
						A__							:   Tuple					       =		initializer_range
						A__							:   Tuple					       =		use_cache
						A__							:   str					       =		hidden_dropout
						A__							:   List[str]					       =		attention_dropout

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

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






					@property
					def   __A      (			self      ):
						return self.hidden_size // self.num_attention_heads






					@property
					def   __A      (			self      ):
						return not self.alibi



