

from argparse import ArgumentParser

from . import BaseTransformersCLICommand


def     __SCREAMING_SNAKE_CASE   (SCREAMING_SNAKE_CASE__			):
						return DownloadCommand(args.model    ,						args.cache_dir    ,						args.force    ,						args.trust_remote_code			)





class       snake_case_  (						__A   ):







			'''simple docstring'''

			@staticmethod
			def 							snake_case__(	_UpperCamelCase					:							ArgumentParser				) ->List[Any]:
									snake_case_  =      parser.add_parser('''download'''				)
									download_parser.add_argument(
									    '''--cache-dir'''				,  type=_UpperCamelCase				,  default=_UpperCamelCase				,  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=_UpperCamelCase				,  help='''Name of the model to download'''				)
									download_parser.set_defaults(func=_UpperCamelCase				)







			def __init__(	self					:							Optional[int]				,  _UpperCamelCase					:							str				,  _UpperCamelCase					:							str				,  _UpperCamelCase					:							bool				,  _UpperCamelCase					:							bool				) ->Any:
									snake_case_  =      model
									snake_case_  =      cache
									snake_case_  =      force
									snake_case_  =      trust_remote_code







			def 							snake_case__(	self					:							str				) ->Dict:
									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				)






'''simple docstring'''






import math

import tensorflow as tf
from packaging import version






def   __A    (				a_    :	List[Any]						):
		lowerCAmelCase  :     Any       						= tf.convert_to_tensor(a_						)
		lowerCAmelCase  :     List[Any]       						= 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0						)   ,x.dtype						)						))

		return x * cdf






def   __A    (				a_    :	int						):
		lowerCAmelCase  :     Dict       						= tf.convert_to_tensor(a_						)
		lowerCAmelCase  :     int       						= tf.cast(math.pi   ,x.dtype						)
		lowerCAmelCase  :     Dict       						= tf.cast(0.0_4_4_7_1_5   ,x.dtype						)
		lowerCAmelCase  :     Dict       						= 0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi						) * (x + coeff * tf.pow(a_   ,3						))						))

		return x * cdf






def   __A    (				a_    :	Union[str, Any]						):
		lowerCAmelCase  :     Any       						= tf.convert_to_tensor(a_						)

		return x * tf.tanh(tf.math.softplus(a_						)						)






def   __A    (				a_    :	List[str]						):
		lowerCAmelCase  :     Dict       						= tf.convert_to_tensor(a_						)
		lowerCAmelCase  :     Any       						= tf.cast(0.0_4_4_7_1_5   ,x.dtype						)
		lowerCAmelCase  :     Optional[int]       						= tf.cast(0.7_9_7_8_8_4_5_6_0_8   ,x.dtype						)

		return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)						))






def   __A    (				a_    :	Union[str, Any]						):
		lowerCAmelCase  :     Optional[int]       						= tf.convert_to_tensor(a_						)
		lowerCAmelCase  :     List[Any]       						= tf.cast(1.7_0_2   ,x.dtype						)
		return x * tf.math.sigmoid(coeff * x						)






def   __A    (				a_    :	List[Any]						):
		return tf.clip_by_value(_gelu(a_						)   ,-1_0   ,1_0						)






def   __A    (				a_    :	List[Any]   ,a_    :	List[Any]=-1						):
		lowerCAmelCase						,		lowerCAmelCase  :     Optional[int]       						= tf.split(a_   ,2   ,axis=a_						)
		return a * tf.math.sigmoid(a_						)


if version.parse(tf.version.VERSION) >= version.parse("""2.4"""):






					def   __A    (				a_    :	Optional[Any]						):
							return tf.keras.activations.gelu(a_   ,approximate=a_						)

					lowerCAmelCase									=   tf.keras.activations.gelu

					lowerCAmelCase									=   approximate_gelu_wrap
else:
					lowerCAmelCase									=   _gelu
					lowerCAmelCase									=   _gelu_new


lowerCAmelCase									=   {
    """gelu""": gelu,
    """gelu_10""": gelu_aa,
    """gelu_fast""": gelu_fast,
    """gelu_new""": gelu_new,
    """glu""": glu,
    """mish""": mish,
    """quick_gelu""": quick_gelu,
    """relu""": tf.keras.activations.relu,
    """sigmoid""": tf.keras.activations.sigmoid,
    """silu""": tf.keras.activations.swish,
    """swish""": tf.keras.activations.swish,
    """tanh""": tf.keras.activations.tanh,
}






def   __A    (				a_    :	int						):
		if activation_string in ACTaFN:
				return ACTaFN[activation_string]
		else:
				raise KeyError(f'''function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()						)}'''						)



