






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


__UpperCAmelCase      =				logging.get_logger(__name__)

__UpperCAmelCase      =				{
    "google/reformer-crime-and-punishment": (
        "https://huggingface.co/google/reformer-crime-and-punishment/resolve/main/config.json"
    ),
    "google/reformer-enwik8": "https://huggingface.co/google/reformer-enwik8/resolve/main/config.json",
}
class 	a_(		lowercase__	):



     """simple docstring"""



     __snake_case		:				List[str]  					='''reformer'''
     __snake_case		:				List[Any]  					=['''past_buckets_states''']
     __snake_case		:				str  					={}





     def __init__(		self					:	str  ,  lowerCAmelCase__					:	Dict=6_4  ,  lowerCAmelCase__					:	Tuple=["local", "lsh", "local", "lsh", "local", "lsh"]  ,  lowerCAmelCase__					:	Optional[Any]=1.0  ,  lowerCAmelCase__					:	List[str]=True  ,  lowerCAmelCase__					:	Tuple=[6_4, 6_4]  ,  lowerCAmelCase__					:	List[Any]=[6_4, 1_9_2]  ,  lowerCAmelCase__					:	Optional[Any]=0  ,  lowerCAmelCase__					:	Tuple=2  ,  lowerCAmelCase__					:	Dict=5_1_2  ,  lowerCAmelCase__					:	List[str]=None  ,  lowerCAmelCase__					:	List[str]="relu"  ,  lowerCAmelCase__					:	Dict=0.05  ,  lowerCAmelCase__					:	int=2_5_6  ,  lowerCAmelCase__					:	Any=0.02  ,  lowerCAmelCase__					:	Optional[Any]=False  ,  lowerCAmelCase__					:	List[str]=1e-12  ,  lowerCAmelCase__					:	Tuple=1  ,  lowerCAmelCase__					:	List[Any]=0  ,  lowerCAmelCase__					:	Optional[int]=0.05  ,  lowerCAmelCase__					:	Optional[int]=6_4  ,  lowerCAmelCase__					:	Optional[Any]=6_4  ,  lowerCAmelCase__					:	int=0.0  ,  lowerCAmelCase__					:	Dict=1  ,  lowerCAmelCase__					:	str=0  ,  lowerCAmelCase__					:	int=4_0_9_6  ,  lowerCAmelCase__					:	int=1_2  ,  lowerCAmelCase__					:	Union[str, Any]=None  ,  lowerCAmelCase__					:	Dict=1  ,  lowerCAmelCase__					:	Dict=0  ,  lowerCAmelCase__					:	Tuple=3_2_0  ,  lowerCAmelCase__					:	Any=False  ,  lowerCAmelCase__					:	Union[str, Any]=True  ,  lowerCAmelCase__					:	Any=None  ,  **lowerCAmelCase__					:	str  ,  )							->	Optional[Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		hash_seed
      SCREAMING_SNAKE_CASE				    =		vocab_size
      SCREAMING_SNAKE_CASE				    =		attention_head_size
      SCREAMING_SNAKE_CASE				    =		hidden_size
      SCREAMING_SNAKE_CASE				    =		num_attention_heads
      SCREAMING_SNAKE_CASE				    =		num_hashes
      SCREAMING_SNAKE_CASE				    =		len(lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		tuple(lowerCAmelCase__) if isinstance(lowerCAmelCase__  ,  lowerCAmelCase__) else num_buckets
      SCREAMING_SNAKE_CASE				    =		lsh_attn_chunk_length
      SCREAMING_SNAKE_CASE				    =		local_attn_chunk_length
      SCREAMING_SNAKE_CASE				    =		lsh_num_chunks_after
      SCREAMING_SNAKE_CASE				    =		lsh_num_chunks_before
      SCREAMING_SNAKE_CASE				    =		local_num_chunks_after
      SCREAMING_SNAKE_CASE				    =		local_num_chunks_before
      SCREAMING_SNAKE_CASE				    =		hidden_act
      SCREAMING_SNAKE_CASE				    =		feed_forward_size
      SCREAMING_SNAKE_CASE				    =		hidden_dropout_prob
      SCREAMING_SNAKE_CASE				    =		lsh_attention_probs_dropout_prob
      SCREAMING_SNAKE_CASE				    =		local_attention_probs_dropout_prob
      SCREAMING_SNAKE_CASE				    =		max_position_embeddings
      SCREAMING_SNAKE_CASE				    =		initializer_range
      SCREAMING_SNAKE_CASE				    =		layer_norm_eps
      SCREAMING_SNAKE_CASE				    =		axial_pos_embds
      SCREAMING_SNAKE_CASE				    =		tuple(lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		tuple(lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		axial_norm_std
      SCREAMING_SNAKE_CASE				    =		chunk_size_lm_head
      SCREAMING_SNAKE_CASE				    =		attn_layers
      SCREAMING_SNAKE_CASE				    =		use_cache
      SCREAMING_SNAKE_CASE				    =		classifier_dropout
      super().__init__(
          pad_token_id=lowerCAmelCase__  ,  eos_token_id=lowerCAmelCase__  ,  is_decoder=lowerCAmelCase__  ,  tie_word_embeddings=lowerCAmelCase__  ,  **lowerCAmelCase__  ,  )












import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard
class 	a_(		unittest.TestCase	):



     """simple docstring"""



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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		{
          'model_details': {
              'Organization': 'testing',
              'Model date': 'today',
              'Model version': 'v2.1, Developed by Test Corp in 2019.',
              'Architecture': 'Convolutional Neural Network.',
          },
          'metrics': 'BLEU and ROUGE-1',
          'evaluation_data': {
              'Datasets': {'BLEU': 'My-great-dataset-v1', 'ROUGE-1': 'My-short-dataset-v2.1'},
              'Preprocessing': 'See details on https://arxiv.org/pdf/1810.03993.pdf',
          },
          'training_data': {
              'Dataset': 'English Wikipedia dump dated 2018-12-01',
              'Preprocessing': (
                  'Using SentencePiece vocabulary of size 52k tokens. See details on'
                  ' https://arxiv.org/pdf/1810.03993.pdf'
              ),
          },
          'quantitative_analyses': {'BLEU': 55.1, 'ROUGE-1': 7_6},
      }





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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		ModelCard.from_dict(self.inputs_dict)
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'model_details'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'intended_use'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'factors'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'metrics'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'evaluation_data'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'training_data'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'quantitative_analyses'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'ethical_considerations'))
      self.assertTrue(hasattr(lowerCAmelCase__  ,  'caveats_and_recommendations'))





     def     __UpperCamelCase						(		self					:	Any)							->	Any:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		ModelCard.from_dict(self.inputs_dict)
      SCREAMING_SNAKE_CASE				    =		json.loads(modelcard.to_json_string())
      for key, value in self.inputs_dict.items():
       self.assertEqual(obj[key]  ,  lowerCAmelCase__)





     def     __UpperCamelCase						(		self					:	int)							->	Optional[Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		ModelCard.from_dict(self.inputs_dict)

      with tempfile.TemporaryDirectory() as tmpdirname:
       SCREAMING_SNAKE_CASE				    =		os.path.join(lowerCAmelCase__  ,  'modelcard.json')
       model_card_first.to_json_file(lowerCAmelCase__)
       SCREAMING_SNAKE_CASE				    =		ModelCard.from_json_file(lowerCAmelCase__)

      self.assertEqual(model_card_second.to_dict()  ,  model_card_first.to_dict())





     def     __UpperCamelCase						(		self					:	Optional[int])							->	Any:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		ModelCard.from_dict(self.inputs_dict)

      with tempfile.TemporaryDirectory() as tmpdirname:
       model_card_first.save_pretrained(lowerCAmelCase__)
       SCREAMING_SNAKE_CASE				    =		ModelCard.from_pretrained(lowerCAmelCase__)

      self.assertEqual(model_card_second.to_dict()  ,  model_card_first.to_dict())




