

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


_lowerCAmelCase         =						logging.get_logger(__name__)

_lowerCAmelCase         =						{
    "facebook/xglm-564M": "https://huggingface.co/facebook/xglm-564M/resolve/main/config.json",
    # See all XGLM models at https://huggingface.co/models?filter=xglm
}






class   _SCREAMING_SNAKE_CASE   (   __a     ):
 __SCREAMING_SNAKE_CASE					:Union[str, Any]      	=					"""xglm"""
 __SCREAMING_SNAKE_CASE					:Union[str, Any]      	=					["""past_key_values"""]

 __SCREAMING_SNAKE_CASE					:str      	=					{
     """num_attention_heads""": """attention_heads""",
     """hidden_size""": """d_model""",
     """num_hidden_layers""": """num_layers""",
 }



 def __init__(   self		:   Dict			,				a__		:   Optional[int]=25_6008			,				a__		:   Dict=2048			,				a__		:   List[Any]=1024			,				a__		:   Optional[Any]=4096			,				a__		:   Optional[int]=24			,				a__		:   str=16			,				a__		:   int="gelu"			,				a__		:   Any=0.1			,				a__		:   Optional[int]=0.1			,				a__		:   str=0.0			,				a__		:   Union[str, Any]=0.0			,				a__		:   List[Any]=0.02			,				a__		:   Tuple=True			,				a__		:   Tuple=True			,				a__		:   Dict=2			,				a__		:   List[str]=1			,				a__		:   str=0			,				a__		:   List[str]=2			,				**a__		:   List[str]			,				):
      __magic_name__						       =    vocab_size
      __magic_name__						       =    max_position_embeddings
      __magic_name__						       =    d_model
      __magic_name__						       =    ffn_dim
      __magic_name__						       =    num_layers
      __magic_name__						       =    attention_heads
      __magic_name__						       =    activation_function
      __magic_name__						       =    dropout
      __magic_name__						       =    attention_dropout
      __magic_name__						       =    activation_dropout
      __magic_name__						       =    layerdrop
      __magic_name__						       =    init_std
      __magic_name__						       =    scale_embedding  # scale factor will be sqrt(d_model) if True
      __magic_name__						       =    use_cache

      super().__init__(
          pad_token_id=a__			,				bos_token_id=a__			,				eos_token_id=a__			,				decoder_start_token_id=a__			,				**a__			,				)









'''simple docstring'''




import re

from flax.core.frozen_dict import freeze
from flax.traverse_util import flatten_dict, unflatten_dict
from jax.experimental import PartitionSpec as P


# Sentinels
_lowerCAmelCase         =						object()

# For specifying empty leaf dict `{}`
_lowerCAmelCase         =						object()




def 						UpperCamelCase	(			a		,						a			)				->     Union[str, Any]:






     '''simple docstring'''
     __magic_name__						       =    tuple((re.compile(x + '''$'''			) for x in qs)			)
     for i in range(len(a			) - len(a			) + 1			):
          __magic_name__						       =    [x.match(a			) for x, y in zip(a		,						ks[i:]			)]
          if matches and all(a			):
               return True
     return False




def 						UpperCamelCase	(			a			)				->     Tuple:






     '''simple docstring'''
     def replace(a		,						a			):
          for rule, replacement in rules:
               if _match(a		,						a			):
                    return replacement
          return val

     return replace




def 						UpperCamelCase	(			)				->     Union[str, Any]:






     '''simple docstring'''
     return [
         # embeddings
         (("transformer", "wpe", "embedding"), P('''mp'''		,						a			)),
         (("transformer", "wte", "embedding"), P('''mp'''		,						a			)),
         # atention
         (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(a		,						'''mp'''			)),
         (("attention", "out_proj", "kernel"), P('''mp'''		,						a			)),
         (("attention", "out_proj", "bias"), None),
         # mlp
         (("mlp", "c_fc", "kernel"), P(a		,						'''mp'''			)),
         (("mlp", "c_fc", "bias"), P('''mp'''			)),
         (("mlp", "c_proj", "kernel"), P('''mp'''		,						a			)),
         (("mlp", "c_proj", "bias"), None),
         # layer norms
         ((r"ln_\d+", "bias"), None),
         ((r"\d+", r"ln_\d+", "scale"), None),
         (("ln_f", "bias"), None),
         (("ln_f", "scale"), None),
     ]




def 						UpperCamelCase	(			a			)				->     str:






     '''simple docstring'''
     __magic_name__						       =    _get_partition_rules()
     __magic_name__						       =    _replacement_rules(a			)
     __magic_name__						       =    {k: _unmatched for k in flatten_dict(a			)}
     __magic_name__						       =    {k: replace(a		,						a			) for k, v in initd.items()}
     assert _unmatched not in result.values(), "Incomplete partition spec."
     return freeze(unflatten_dict(a			)			)






