



from collections import OrderedDict
from typing import Any, List, Mapping, Optional

from ... import PreTrainedTokenizer, TensorType, is_torch_available
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import logging


a__   :					int 						=      logging.get_logger(__name__)

a__   :					str 						=      {
    "EleutherAI/gpt-j-6B": "https://huggingface.co/EleutherAI/gpt-j-6B/resolve/main/config.json",
    # See all GPT-J models at https://huggingface.co/models?filter=gpt_j
}



class    UpperCAmelCase__(				lowerCamelCase						):

   '''simple docstring'''




   A     :	Optional[int]												=     "gptj"
   A     :	Tuple												=     {
       "max_position_embeddings": "n_positions",
       "hidden_size": "n_embd",
       "num_attention_heads": "n_head",
       "num_hidden_layers": "n_layer",
   }


   def __init__(    self	:      Any      ,					lowerCAmelCase	:      Dict=5_04_00      ,					lowerCAmelCase	:      List[Any]=20_48      ,					lowerCAmelCase	:      int=40_96      ,					lowerCAmelCase	:      List[str]=28      ,					lowerCAmelCase	:      Any=16      ,					lowerCAmelCase	:      Optional[Any]=64      ,					lowerCAmelCase	:      Dict=None      ,					lowerCAmelCase	:      int="gelu_new"      ,					lowerCAmelCase	:      int=0.0      ,					lowerCAmelCase	:      Dict=0.0      ,					lowerCAmelCase	:      Union[str, Any]=0.0      ,					lowerCAmelCase	:      Dict=1E-5      ,					lowerCAmelCase	:      Dict=0.02      ,					lowerCAmelCase	:      str=True      ,					lowerCAmelCase	:      str=5_02_56      ,					lowerCAmelCase	:      Any=5_02_56      ,					lowerCAmelCase	:      Optional[int]=False      ,					**lowerCAmelCase	:      Dict      ,					)						->					Optional[Any]:




         """simple docstring"""

         lowercase__  =	vocab_size
         lowercase__  =	n_positions
         lowercase__  =	n_embd
         lowercase__  =	n_layer
         lowercase__  =	n_head
         lowercase__  =	n_inner
         lowercase__  =	rotary_dim
         lowercase__  =	activation_function
         lowercase__  =	resid_pdrop
         lowercase__  =	embd_pdrop
         lowercase__  =	attn_pdrop
         lowercase__  =	layer_norm_epsilon
         lowercase__  =	initializer_range
         lowercase__  =	use_cache

         lowercase__  =	bos_token_id
         lowercase__  =	eos_token_id

         super().__init__(
             bos_token_id=lowerCAmelCase      ,					eos_token_id=lowerCAmelCase      ,					tie_word_embeddings=lowerCAmelCase      ,					**lowerCAmelCase)



class    UpperCAmelCase__(				lowerCamelCase						):

   '''simple docstring'''




   def __init__(    self	:      List[str]      ,					lowerCAmelCase	:      PretrainedConfig      ,					lowerCAmelCase	:      str = "default"      ,					lowerCAmelCase	:      List[PatchingSpec] = None      ,					lowerCAmelCase	:      bool = False      ,					)						->					Optional[Any]:




         """simple docstring"""

         super().__init__(lowerCAmelCase      ,					task=lowerCAmelCase      ,					patching_specs=lowerCAmelCase      ,					use_past=lowerCAmelCase)
         if not getattr(self._config      ,					'pad_token_id'      ,					lowerCAmelCase):
               # TODO: how to do that better?
               lowercase__  =	0


   @property
   def       UpperCAmelCase		(    self	:      List[str])						->					Mapping[str, Mapping[int, str]]:




         """simple docstring"""

         lowercase__  =	OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}})
         if self.use_past:
               self.fill_with_past_key_values_(lowerCAmelCase      ,					direction='inputs')
               lowercase__  =	{0: 'batch', 1: 'past_sequence + sequence'}
         else:
               lowercase__  =	{0: 'batch', 1: 'sequence'}

         return common_inputs


   @property
   def       UpperCAmelCase		(    self	:      Optional[int])						->					int:




         """simple docstring"""

         return self._config.n_layer


   @property
   def       UpperCAmelCase		(    self	:      str)						->					int:




         """simple docstring"""

         return self._config.n_head


   def       UpperCAmelCase		(    self	:      Union[str, Any]      ,					lowerCAmelCase	:      PreTrainedTokenizer      ,					lowerCAmelCase	:      int = -1      ,					lowerCAmelCase	:      int = -1      ,					lowerCAmelCase	:      bool = False      ,					lowerCAmelCase	:      Optional[TensorType] = None      ,					)						->					Mapping[str, Any]:




         """simple docstring"""

         lowercase__  =	super(lowerCAmelCase      ,					self).generate_dummy_inputs(
             lowerCAmelCase      ,					batch_size=lowerCAmelCase      ,					seq_length=lowerCAmelCase      ,					is_pair=lowerCAmelCase      ,					framework=lowerCAmelCase)

         # We need to order the input in the way they appears in the forward()
         lowercase__  =	OrderedDict({'input_ids': common_inputs['input_ids']})

         # Need to add the past_keys
         if self.use_past:
               if not is_torch_available():
                     raise ValueError('Cannot generate dummy past_keys inputs without PyTorch installed.')
               else:
                     import torch

                     lowercase__,						lowercase__  =	common_inputs['input_ids'].shape
                     # Not using the same length for past_key_values
                     lowercase__  =	seqlen + 2
                     lowercase__  =	(
                         batch,
                         self.num_attention_heads,
                         past_key_values_length,
                         self._config.hidden_size // self.num_attention_heads,
                     )
                     lowercase__  =	[
                         (torch.zeros(lowerCAmelCase), torch.zeros(lowerCAmelCase)) for _ in range(self.num_layers)
                     ]

         lowercase__  =	common_inputs['attention_mask']
         if self.use_past:
               lowercase__  =	ordered_inputs['attention_mask'].dtype
               lowercase__  =	torch.cat(
                   [ordered_inputs['attention_mask'], torch.ones(lowerCAmelCase      ,					lowerCAmelCase      ,					dtype=lowerCAmelCase)]      ,					dim=1)

         return ordered_inputs



   @property
   def       UpperCAmelCase		(    self	:      Union[str, Any])						->					int:




         """simple docstring"""

         return 13





def 	_lowerCAmelCase (    A__ = 50_000_000						):
      lowercase__  =	set()
      lowercase__  =	int((limit - 24) ** (1 / 2)						)

      lowercase__  =	set(range(3    ,	prime_square_limit + 1    ,	2						)						)
      primes.add(2						)
      for p in range(3    ,	prime_square_limit + 1    ,	2						):
            if p not in primes:
                  continue
            primes.difference_update(set(range(p * p    ,	prime_square_limit + 1    ,	A__						)						)						)

      for primea in primes:
            lowercase__  =	primea * primea
            for primea in primes:
                  lowercase__  =	primea * primea * primea
                  if square + cube >= limit - 16:
                        break
                  for primea in primes:
                        lowercase__  =	primea * primea * primea * primea
                        lowercase__  =	square + cube + tetr
                        if total >= limit:
                              break
                        ret.add(A__						)

      return len(A__						)


if __name__ == "__main__":
       print(F'''{solution() = }''')
