



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


__A   			=logging.get_logger(__name__)

__A   			={
    "tanreinama/GPTSAN-2.8B-spout_is_uniform": (
        "https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json"
    ),
}

class 		UpperCAmelCase__			(			__UpperCamelCase   ):




			'''simple docstring'''






			UpperCamelCase									=       """gptsan-japanese"""
			UpperCamelCase									=       [
			    """past_key_values""",
			]
			UpperCamelCase									=       {
			    """hidden_size""": """d_model""",
			    """num_attention_heads""": """num_heads""",
			    """num_hidden_layers""": """num_layers""",
			}




			def __init__(   self							: Any       ,       a_							: Tuple=3_60_00       ,       a_							: Dict=12_80       ,       a_							: Optional[Any]=10_24       ,       a_							: Optional[int]=81_92       ,       a_							: List[str]=40_96       ,       a_							: Tuple=1_28       ,       a_							: Tuple=10       ,       a_							: Union[str, Any]=0       ,       a_							: Any=16       ,       a_							: int=16       ,       a_							: List[str]=1_28       ,       a_							: str=0.0       ,       a_							: Union[str, Any]=1e-5       ,       a_							: Optional[int]=False       ,       a_							: Any=0.0       ,       a_							: Optional[Any]="float32"       ,       a_							: Optional[Any]=False       ,       a_							: Tuple=False       ,       a_							: Dict=False       ,       a_							: Optional[Any]=0.0_0_2       ,       a_							: Dict=False       ,       a_							: Optional[int]=True       ,       a_							: str=3_59_98       ,       a_							: List[Any]=3_59_95       ,       a_							: Optional[int]=3_59_99       ,       **a_							: List[str]       ,       ):
					'''simple docstring'''





					__UpperCAmelCase    :     int													=	vocab_size
					__UpperCAmelCase    :     Optional[int]													=	max_position_embeddings
					__UpperCAmelCase    :     List[Any]													=	d_model
					__UpperCAmelCase    :     Any													=	d_ff
					__UpperCAmelCase    :     List[Any]													=	d_ext
					__UpperCAmelCase    :     Tuple													=	d_spout
					__UpperCAmelCase    :     int													=	num_switch_layers
					__UpperCAmelCase    :     Dict													=	num_ext_layers
					__UpperCAmelCase    :     str													=	num_switch_layers + num_ext_layers
					__UpperCAmelCase    :     Any													=	num_heads
					__UpperCAmelCase    :     Optional[Any]													=	num_experts
					__UpperCAmelCase    :     List[str]													=	expert_capacity
					__UpperCAmelCase    :     List[str]													=	dropout_rate
					__UpperCAmelCase    :     Optional[int]													=	layer_norm_epsilon
					__UpperCAmelCase    :     Optional[Any]													=	router_bias
					__UpperCAmelCase    :     List[Any]													=	router_jitter_noise
					__UpperCAmelCase    :     Union[str, Any]													=	router_dtype
					__UpperCAmelCase    :     Optional[int]													=	router_ignore_padding_tokens
					__UpperCAmelCase    :     Dict													=	output_hidden_states
					__UpperCAmelCase    :     Tuple													=	output_attentions
					__UpperCAmelCase    :     Optional[int]													=	initializer_factor
					__UpperCAmelCase    :     Any													=	output_router_logits
					__UpperCAmelCase    :     Any													=	use_cache

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










import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format

class 		UpperCAmelCase__			:




			'''simple docstring'''






			UpperCamelCase									=       None




			def  snake_case__     (   self							: List[str] ):
					'''simple docstring'''





					__UpperCAmelCase    :     List[Any]													=	self.feature_extraction_class(**self.feat_extract_dict )
					__UpperCAmelCase    :     Optional[int]													=	json.loads(feat_extract.to_json_string() )
					for key, value in self.feat_extract_dict.items():
							self.assertEqual(obj[key]       ,       a_ )




			def  snake_case__     (   self							: Any ):
					'''simple docstring'''





					__UpperCAmelCase    :     str													=	self.feature_extraction_class(**self.feat_extract_dict )

					with tempfile.TemporaryDirectory() as tmpdirname:
							__UpperCAmelCase    :     Union[str, Any]													=	os.path.join(a_       ,       '''feat_extract.json''' )
							feat_extract_first.to_json_file(a_ )
							__UpperCAmelCase    :     Any													=	self.feature_extraction_class.from_json_file(a_ )

					self.assertEqual(feat_extract_second.to_dict()       ,       feat_extract_first.to_dict() )




			def  snake_case__     (   self							: Optional[int] ):
					'''simple docstring'''





					__UpperCAmelCase    :     Tuple													=	self.feature_extraction_class(**self.feat_extract_dict )

					with tempfile.TemporaryDirectory() as tmpdirname:
							__UpperCAmelCase    :     List[str]													=	feat_extract_first.save_pretrained(a_ )[0]
							check_json_file_has_correct_format(a_ )
							__UpperCAmelCase    :     Optional[Any]													=	self.feature_extraction_class.from_pretrained(a_ )

					self.assertEqual(feat_extract_second.to_dict()       ,       feat_extract_first.to_dict() )




			def  snake_case__     (   self							: Dict ):
					'''simple docstring'''





					__UpperCAmelCase    :     int													=	self.feature_extraction_class()
					self.assertIsNotNone(a_ )





