




import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
 import jax.numpy as jnp

if is_tf_available():
 import tensorflow as tf

if is_torch_available():
 import torch







class 						A(		unittest.TestCase     ):



 '''simple docstring'''


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

       """simple docstring"""






       lowerCamelCase_	  =					{
           'task_specific_params': {
               'summarization': {'length_penalty': 1.0, 'max_length': 128, 'min_length': 12, 'num_beams': 4},
               'summarization_cnn': {'length_penalty': 2.0, 'max_length': 142, 'min_length': 56, 'num_beams': 4},
               'summarization_xsum': {'length_penalty': 1.0, 'max_length': 62, 'min_length': 11, 'num_beams': 6},
           }
       }
       lowerCamelCase_	  =					{
           'task_specific_params.summarization.length_penalty': 1.0,
           'task_specific_params.summarization.max_length': 128,
           'task_specific_params.summarization.min_length': 12,
           'task_specific_params.summarization.num_beams': 4,
           'task_specific_params.summarization_cnn.length_penalty': 2.0,
           'task_specific_params.summarization_cnn.max_length': 142,
           'task_specific_params.summarization_cnn.min_length': 56,
           'task_specific_params.summarization_cnn.num_beams': 4,
           'task_specific_params.summarization_xsum.length_penalty': 1.0,
           'task_specific_params.summarization_xsum.max_length': 62,
           'task_specific_params.summarization_xsum.min_length': 11,
           'task_specific_params.summarization_xsum.num_beams': 6,
       }

       self.assertEqual(flatten_dict(A_						)		,							A_						)

 def        a__				(       self      :						Optional[int]						)     ->			List[str]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       self.assertTrue(np.allclose(transpose(A_						)		,							x.transpose()						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       self.assertTrue(np.allclose(transpose(A_		,							axes=(1, 2, 0)						)		,							x.transpose((1, 2, 0)						)						)						)

 @require_torch
 def        a__				(       self      :						Union[str, Any]						)     ->			Dict:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(transpose(A_						)		,							transpose(A_						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(transpose(A_		,							axes=(1, 2, 0)						)		,							transpose(A_		,							axes=(1, 2, 0)						).numpy()						)						)

 @require_tf
 def        a__				(       self      :						int						)     ->			List[Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(transpose(A_						)		,							transpose(A_						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(transpose(A_		,							axes=(1, 2, 0)						)		,							transpose(A_		,							axes=(1, 2, 0)						).numpy()						)						)

 @require_flax
 def        a__				(       self      :						Any						)     ->			Optional[Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(transpose(A_						)		,							np.asarray(transpose(A_						)						)						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(transpose(A_		,							axes=(1, 2, 0)						)		,							np.asarray(transpose(A_		,							axes=(1, 2, 0)						)						)						)						)

 def        a__				(       self      :						List[Any]						)     ->			Any:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       self.assertTrue(np.allclose(reshape(A_		,							(4, 3)						)		,							np.reshape(A_		,							(4, 3)						)						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       self.assertTrue(np.allclose(reshape(A_		,							(12, 5)						)		,							np.reshape(A_		,							(12, 5)						)						)						)

 @require_torch
 def        a__				(       self      :						Union[str, Any]						)     ->			List[Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(4, 3)						)		,							reshape(A_		,							(4, 3)						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(12, 5)						)		,							reshape(A_		,							(12, 5)						).numpy()						)						)

 @require_tf
 def        a__				(       self      :						Any						)     ->			Any:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(4, 3)						)		,							reshape(A_		,							(4, 3)						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(12, 5)						)		,							reshape(A_		,							(12, 5)						).numpy()						)						)

 @require_flax
 def        a__				(       self      :						Optional[Any]						)     ->			List[str]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(4, 3)						)		,							np.asarray(reshape(A_		,							(4, 3)						)						)						)						)

       lowerCamelCase_	  =					np.random.randn(3		,							4		,							5						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(reshape(A_		,							(12, 5)						)		,							np.asarray(reshape(A_		,							(12, 5)						)						)						)						)

 def        a__				(       self      :						Optional[Any]						)     ->			Any:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(1		,							3		,							4						)
       self.assertTrue(np.allclose(squeeze(A_						)		,							np.squeeze(A_						)						)						)

       lowerCamelCase_	  =					np.random.randn(1		,							4		,							1		,							5						)
       self.assertTrue(np.allclose(squeeze(A_		,							axis=2						)		,							np.squeeze(A_		,							axis=2						)						)						)

 @require_torch
 def        a__				(       self      :						Tuple						)     ->			Optional[int]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(1		,							3		,							4						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(squeeze(A_						)		,							squeeze(A_						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(1		,							4		,							1		,							5						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(squeeze(A_		,							axis=2						)		,							squeeze(A_		,							axis=2						).numpy()						)						)

 @require_tf
 def        a__				(       self      :						Union[str, Any]						)     ->			Union[str, Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(1		,							3		,							4						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(squeeze(A_						)		,							squeeze(A_						).numpy()						)						)

       lowerCamelCase_	  =					np.random.randn(1		,							4		,							1		,							5						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(squeeze(A_		,							axis=2						)		,							squeeze(A_		,							axis=2						).numpy()						)						)

 @require_flax
 def        a__				(       self      :						List[str]						)     ->			str:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(1		,							3		,							4						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(squeeze(A_						)		,							np.asarray(squeeze(A_						)						)						)						)

       lowerCamelCase_	  =					np.random.randn(1		,							4		,							1		,							5						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(squeeze(A_		,							axis=2						)		,							np.asarray(squeeze(A_		,							axis=2						)						)						)						)

 def        a__				(       self      :						List[Any]						)     ->			Optional[Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       self.assertTrue(np.allclose(expand_dims(A_		,							axis=1						)		,							np.expand_dims(A_		,							axis=1						)						)						)

 @require_torch
 def        a__				(       self      :						Dict						)     ->			Union[str, Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					torch.tensor(A_						)
       self.assertTrue(np.allclose(expand_dims(A_		,							axis=1						)		,							expand_dims(A_		,							axis=1						).numpy()						)						)

 @require_tf
 def        a__				(       self      :						List[Any]						)     ->			Union[str, Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					tf.constant(A_						)
       self.assertTrue(np.allclose(expand_dims(A_		,							axis=1						)		,							expand_dims(A_		,							axis=1						).numpy()						)						)





 @require_flax
 def        a__				(       self      :						Dict						)     ->			Union[str, Any]:

       """simple docstring"""






       lowerCamelCase_	  =					np.random.randn(3		,							4						)
       lowerCamelCase_	  =					jnp.array(A_						)
       self.assertTrue(np.allclose(expand_dims(A_		,							axis=1						)		,							np.asarray(expand_dims(A_		,							axis=1						)						)						)						)









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


lowerCamelCase       :	str									=     logging.get_logger(__name__)

lowerCamelCase       :	List[str]									=     {
    "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json",
}







class 						A(		UpperCamelCase     ):



 '''simple docstring'''


 UpperCamelCase		     =		'''gpt_neox_japanese'''

 def __init__(       self      :						int		,							A_      :						Dict=32000		,							A_      :						List[Any]=2560		,							A_      :						Dict=32		,							A_      :						Union[str, Any]=32		,							A_      :						List[Any]=4		,							A_      :						List[str]="gelu"		,							A_      :						Dict=1.00		,							A_      :						int=10000		,							A_      :						Dict=2048		,							A_      :						Dict=0.02		,							A_      :						Any=1E-5		,							A_      :						Union[str, Any]=True		,							A_      :						int=31996		,							A_      :						List[str]=31999		,							A_      :						List[Any]=0.1		,							A_      :						List[Any]=0.0		,							**A_      :						Tuple		,							)     ->			Dict:

       """simple docstring"""






       super().__init__(bos_token_id=A_		,							eos_token_id=A_		,							**A_						)
       lowerCamelCase_	  =					vocab_size
       lowerCamelCase_	  =					max_position_embeddings
       lowerCamelCase_	  =					hidden_size
       lowerCamelCase_	  =					num_hidden_layers
       lowerCamelCase_	  =					num_attention_heads
       lowerCamelCase_	  =					intermediate_multiple_size
       lowerCamelCase_	  =					hidden_act
       lowerCamelCase_	  =					rotary_pct
       lowerCamelCase_	  =					rotary_emb_base
       lowerCamelCase_	  =					initializer_range
       lowerCamelCase_	  =					layer_norm_eps
       lowerCamelCase_	  =					use_cache
       lowerCamelCase_	  =					attention_dropout
       lowerCamelCase_	  =					hidden_dropout



