





'''simple docstring'''






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


lowerCAmelCase       		=      logging.get_logger(__name__)

lowerCAmelCase       		=      {
    """google/switch-base-8""": """https://huggingface.co/google/switch-base-8/blob/main/config.json""",
}
class 		lowerCamelCase  (      _A       ):
	snake_case_      =   "switch_transformers"
	snake_case_      =   ["past_key_values"]
	snake_case_      =   {"hidden_size": "d_model", "num_attention_heads": "num_heads", "num_hidden_layers": "num_layers"}



	def __init__(   self		,      a_=32_128		,      a_=768		,      a_=64		,      a_=2_048		,      a_=64		,      a_=12		,      a_=3		,      a_=12		,      a_=3		,      a_=12		,      a_=8		,      a_=False		,      a_=0.01		,      a_="float32"		,      a_=False		,      a_=32		,      a_=128		,      a_=0.1		,      a_=1e-6		,      a_=0.001		,      a_=0.001		,      a_=1.0		,      a_="relu"		,      a_=True		,      a_=False		,      a_=True		,      a_=0		,      a_=1		,      **a_		,      ):
			lowerCAmelCase     :    int						=   vocab_size
			lowerCAmelCase     :    List[str]						=   d_model
			lowerCAmelCase     :    Tuple						=   d_kv
			lowerCAmelCase     :    Dict						=   d_ff

			lowerCAmelCase     :    Optional[Any]						=   num_sparse_encoder_layers

			lowerCAmelCase     :    Tuple						=   num_layers
			lowerCAmelCase     :    List[Any]						=   (
			    num_decoder_layers if num_decoder_layers is not None else self.num_layers
			)  # default = symmetry
			lowerCAmelCase     :    List[str]						=   num_sparse_decoder_layers

			# This tells us, each how many encoder layer we'll have to set a sparse layer.
			if self.num_sparse_encoder_layers > 0:
					lowerCAmelCase     :    str						=   self.num_layers // self.num_sparse_encoder_layers
			else:
					lowerCAmelCase     :    Optional[Any]						=   self.num_layers  # HACK: this will create 0 sparse layers

			# This tells us, each how many encoder layer we'll have to set a sparse layer.
			if self.num_sparse_decoder_layers > 0:
					lowerCAmelCase     :    str						=   self.num_decoder_layers // self.num_sparse_decoder_layers
			else:
					lowerCAmelCase     :    int						=   self.num_decoder_layers  # HACK: this will create 0 sparse layers

			lowerCAmelCase     :    Optional[int]						=   num_heads
			lowerCAmelCase     :    Any						=   num_experts
			lowerCAmelCase     :    str						=   expert_capacity
			lowerCAmelCase     :    str						=   router_bias
			lowerCAmelCase     :    Optional[int]						=   router_jitter_noise
			if router_dtype not in ["float32", "float16", "bfloat16"]:
					raise ValueError(F'''`router_dtype` must be one of \'float32\', \'float16\' or \'bfloat16\', got {router_dtype}'''	)
			lowerCAmelCase     :    str						=   router_dtype

			lowerCAmelCase     :    Tuple						=   router_ignore_padding_tokens
			lowerCAmelCase     :    Dict						=   relative_attention_num_buckets
			lowerCAmelCase     :    Tuple						=   relative_attention_max_distance

			lowerCAmelCase     :    List[str]						=   dropout_rate
			lowerCAmelCase     :    Any						=   layer_norm_epsilon
			lowerCAmelCase     :    Optional[int]						=   initializer_factor
			lowerCAmelCase     :    Any						=   feed_forward_proj
			lowerCAmelCase     :    List[Any]						=   use_cache
			lowerCAmelCase     :    List[str]						=   add_router_probs

			lowerCAmelCase     :    Optional[int]						=   router_z_loss_coef
			lowerCAmelCase     :    List[Any]						=   router_aux_loss_coef

			lowerCAmelCase     :    Optional[int]						=   self.feed_forward_proj.split("-"	)
			lowerCAmelCase     :    Optional[Any]						=   act_info[-1]
			lowerCAmelCase     :    Tuple						=   act_info[0] == "gated"

			if len(a_	) > 1 and act_info[0] != "gated" or len(a_	) > 2:
					raise ValueError(
					    F'''`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer.'''
					    "Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. "
					    "'gated-gelu' or 'relu'"	)

			# for backwards compatibility
			if feed_forward_proj == "gated-gelu":
					lowerCAmelCase     :    int						=   "gelu_new"

			super().__init__(
			    pad_token_id=a_		,      eos_token_id=a_		,      is_encoder_decoder=a_		,      **a_		,      )










'''simple docstring'''






import numpy as np






def      __A						(							a_						:  np.array	):
		return (2 / (1 + np.exp(-2 * vector	))) - 1


if __name__ == "__main__":
					import doctest

					doctest.testmod()



