





"""simple docstring"""





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


__A											=						logging.get_logger(__name__)

__A											=						{
    """google/switch-base-8""": """https://huggingface.co/google/switch-base-8/blob/main/config.json""",
}






class    _lowerCAmelCase  (	a			):
       """simple docstring"""




       __magic_name__	:Optional[int]						    =   """switch_transformers"""
       __magic_name__	:Optional[Any]						    =   ["""past_key_values"""]
       __magic_name__	:str						    =   {"""hidden_size""": """d_model""", """num_attention_heads""": """num_heads""", """num_hidden_layers""": """num_layers"""}






       def __init__(       self       ,					__UpperCAmelCase=3_2_1_2_8       ,					__UpperCAmelCase=7_6_8       ,					__UpperCAmelCase=6_4       ,					__UpperCAmelCase=2_0_4_8       ,					__UpperCAmelCase=6_4       ,					__UpperCAmelCase=1_2       ,					__UpperCAmelCase=3       ,					__UpperCAmelCase=1_2       ,					__UpperCAmelCase=3       ,					__UpperCAmelCase=1_2       ,					__UpperCAmelCase=8       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=0.01       ,					__UpperCAmelCase="float32"       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=3_2       ,					__UpperCAmelCase=1_2_8       ,					__UpperCAmelCase=0.1       ,					__UpperCAmelCase=1E-6       ,					__UpperCAmelCase=0.0_01       ,					__UpperCAmelCase=0.0_01       ,					__UpperCAmelCase=1.0       ,					__UpperCAmelCase="relu"       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=0       ,					__UpperCAmelCase=1       ,					**__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :Union[str, Any]											=				vocab_size
         lowerCAmelCase__     :int											=				d_model
         lowerCAmelCase__     :Union[str, Any]											=				d_kv
         lowerCAmelCase__     :Dict											=				d_ff

         lowerCAmelCase__     :List[str]											=				num_sparse_encoder_layers

         lowerCAmelCase__     :Union[str, Any]											=				num_layers
         lowerCAmelCase__     :int											=				(
             num_decoder_layers if num_decoder_layers is not None else self.num_layers
         )  # default = symmetry
         lowerCAmelCase__     :List[Any]											=				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__     :Optional[Any]											=				self.num_layers // self.num_sparse_encoder_layers
         else:
           lowerCAmelCase__     :Optional[int]											=				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__     :List[str]											=				self.num_decoder_layers // self.num_sparse_decoder_layers
         else:
           lowerCAmelCase__     :Optional[int]											=				self.num_decoder_layers  # HACK: this will create 0 sparse layers

         lowerCAmelCase__     :List[str]											=				num_heads
         lowerCAmelCase__     :Dict											=				num_experts
         lowerCAmelCase__     :Optional[Any]											=				expert_capacity
         lowerCAmelCase__     :Union[str, Any]											=				router_bias
         lowerCAmelCase__     :Optional[Any]											=				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__     :int											=				router_ignore_padding_tokens
         lowerCAmelCase__     :Dict											=				relative_attention_num_buckets
         lowerCAmelCase__     :Dict											=				relative_attention_max_distance

         lowerCAmelCase__     :str											=				dropout_rate
         lowerCAmelCase__     :List[Any]											=				layer_norm_epsilon
         lowerCAmelCase__     :List[str]											=				initializer_factor
         lowerCAmelCase__     :List[Any]											=				feed_forward_proj
         lowerCAmelCase__     :str											=				use_cache
         lowerCAmelCase__     :Any											=				add_router_probs

         lowerCAmelCase__     :List[Any]											=				router_z_loss_coef
         lowerCAmelCase__     :List[str]											=				router_aux_loss_coef

         lowerCAmelCase__     :Union[str, Any]											=				self.feed_forward_proj.split('-' )
         lowerCAmelCase__     :Dict											=				act_info[-1]
         lowerCAmelCase__     :str											=				act_info[0] == 'gated'

         if len(__UpperCAmelCase ) > 1 and act_info[0] != "gated" or len(__UpperCAmelCase ) > 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__     :Tuple											=				'gelu_new'

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







"""simple docstring"""





# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__A											=						{
    """configuration_mgp_str""": ["""MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MgpstrConfig"""],
    """processing_mgp_str""": ["""MgpstrProcessor"""],
    """tokenization_mgp_str""": ["""MgpstrTokenizer"""],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __A											=						[
      """MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """MgpstrModel""",
      """MgpstrPreTrainedModel""",
      """MgpstrForSceneTextRecognition""",
  ]

if TYPE_CHECKING:
  from .configuration_mgp_str import MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP, MgpstrConfig
  from .processing_mgp_str import MgpstrProcessor
  from .tokenization_mgp_str import MgpstrTokenizer

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mgp_str import (
        MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST,
        MgpstrForSceneTextRecognition,
        MgpstrModel,
        MgpstrPreTrainedModel,
    )
else:
  import sys

  __A											=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
