






"""simple docstring"""







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 					lowerCamelCase__					(       a_ ):
    SCREAMING_SNAKE_CASE		=			'reformer'
    SCREAMING_SNAKE_CASE		=			['past_buckets_states']
    SCREAMING_SNAKE_CASE		=			{}






    def __init__( self	,A=64	,A=["local", "lsh", "local", "lsh", "local", "lsh"]	,A=1.0	,A=True	,A=[64, 64]	,A=[64, 192]	,A=0	,A=2	,A=512	,A=None	,A="relu"	,A=0.05	,A=256	,A=0.02	,A=False	,A=1e-1_2	,A=1	,A=0	,A=0.05	,A=64	,A=64	,A=0.0	,A=1	,A=0	,A=4_096	,A=12	,A=None	,A=1	,A=0	,A=320	,A=False	,A=True	,A=None	,**A	,):
          UpperCAmelCase							=       hash_seed
          UpperCAmelCase							=       vocab_size
          UpperCAmelCase							=       attention_head_size
          UpperCAmelCase							=       hidden_size
          UpperCAmelCase							=       num_attention_heads
          UpperCAmelCase							=       num_hashes
          UpperCAmelCase							=       len(snake_case__					)
          UpperCAmelCase							=       tuple(snake_case__					) if isinstance(snake_case__	,snake_case__					) else num_buckets
          UpperCAmelCase							=       lsh_attn_chunk_length
          UpperCAmelCase							=       local_attn_chunk_length
          UpperCAmelCase							=       lsh_num_chunks_after
          UpperCAmelCase							=       lsh_num_chunks_before
          UpperCAmelCase							=       local_num_chunks_after
          UpperCAmelCase							=       local_num_chunks_before
          UpperCAmelCase							=       hidden_act
          UpperCAmelCase							=       feed_forward_size
          UpperCAmelCase							=       hidden_dropout_prob
          UpperCAmelCase							=       lsh_attention_probs_dropout_prob
          UpperCAmelCase							=       local_attention_probs_dropout_prob
          UpperCAmelCase							=       max_position_embeddings
          UpperCAmelCase							=       initializer_range
          UpperCAmelCase							=       layer_norm_eps
          UpperCAmelCase							=       axial_pos_embds
          UpperCAmelCase							=       tuple(snake_case__					)
          UpperCAmelCase							=       tuple(snake_case__					)
          UpperCAmelCase							=       axial_norm_std
          UpperCAmelCase							=       chunk_size_lm_head
          UpperCAmelCase							=       attn_layers
          UpperCAmelCase							=       use_cache
          UpperCAmelCase							=       classifier_dropout
          super().__init__(
              pad_token_id=snake_case__	,eos_token_id=snake_case__	,is_decoder=snake_case__	,tie_word_embeddings=snake_case__	,**snake_case__	,)











"""simple docstring"""







from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available






def 					_lowerCAmelCase				(					lowerCAmelCase						):







       '''simple docstring'''
       if is_torch_available():
              import torch

              if isinstance(lowerCAmelCase		,					torch.Tensor						):
                     return True

       return isinstance(lowerCAmelCase		,					np.ndarray						)





class      UpperCamelCase_       (				a_     ):



  def 						UpperCamelCase_ (					self )	->	Dict:



         """simple docstring"""





         UpperCAmelCase					=	fields(self )

         # Safety and consistency checks
         if not len(snake_case__ ):
                raise ValueError(f'''{self.__class__.__name__} has no fields.''' )

         UpperCAmelCase					=	getattr(self       ,						class_fields[0].name )
         UpperCAmelCase					=	all(getattr(self       ,						field.name ) is None for field in class_fields[1:] )

         if other_fields_are_none and isinstance(snake_case__       ,						snake_case__ ):
                for key, value in first_field.items():
                       UpperCAmelCase					=	value
         else:
                for field in class_fields:
                       UpperCAmelCase					=	getattr(self       ,						field.name )
                       if v is not None:
                              UpperCAmelCase					=	v



  def __delitem__(					self       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





         raise Exception(f'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.''' )



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	List[str]:



         """simple docstring"""





         raise Exception(f'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.''' )



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





         raise Exception(f'''You cannot use ``pop`` on a {self.__class__.__name__} instance.''' )



  def 						UpperCamelCase_ (					self       ,						*snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





         raise Exception(f'''You cannot use ``update`` on a {self.__class__.__name__} instance.''' )



  def __getitem__(					self       ,						snake_case__ )	->	List[Any]:



         """simple docstring"""





         if isinstance(snake_case__       ,						snake_case__ ):
                UpperCAmelCase					=	dict(self.items() )
                return inner_dict[k]
         else:
                return self.to_tuple()[k]



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



         """simple docstring"""





         if name in self.keys() and value is not None:
                # Don't call self.__setitem__ to avoid recursion errors
                super().__setitem__(snake_case__       ,						snake_case__ )
         super().__setattr__(snake_case__       ,						snake_case__ )



  def __setitem__(					self       ,						snake_case__       ,						snake_case__ )	->	Tuple:



         """simple docstring"""





         super().__setitem__(snake_case__       ,						snake_case__ )
         # Don't call self.__setattr__ to avoid recursion errors
         super().__setattr__(snake_case__       ,						snake_case__ )



  def 						UpperCamelCase_ (					self )	->	Tuple[Any]:



         """simple docstring"""





         return tuple(self[k] for k in self.keys() )
