





'''simple docstring'''






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__							:  Any    =logging.get_logger(__name__)

A__							:  Tuple    ={
    '''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	(     snake_case_  ):
      _lowercase:     List[Any]			=  '''gptj'''
      _lowercase:     Any			=  {
          '''max_position_embeddings''': '''n_positions''',
          '''hidden_size''': '''n_embd''',
          '''num_attention_heads''': '''n_head''',
          '''num_hidden_layers''': '''n_layer''',
      }




      def __init__(     self     :					Optional[int]     ,     __snake_case     :					Tuple=5_04_00     ,     __snake_case     :					Optional[int]=20_48     ,     __snake_case     :					List[Any]=40_96     ,     __snake_case     :					int=28     ,     __snake_case     :					Tuple=16     ,     __snake_case     :					List[str]=64     ,     __snake_case     :					Optional[int]=None     ,     __snake_case     :					int="gelu_new"     ,     __snake_case     :					int=0.0     ,     __snake_case     :					Any=0.0     ,     __snake_case     :					Tuple=0.0     ,     __snake_case     :					Any=1E-5     ,     __snake_case     :					Tuple=0.02     ,     __snake_case     :					Tuple=True     ,     __snake_case     :					Optional[int]=5_02_56     ,     __snake_case     :					Optional[int]=5_02_56     ,     __snake_case     :					Union[str, Any]=False     ,     **__snake_case     :					Optional[int]     ,     )							-> List[str]:
            _lowerCAmelCase					=				vocab_size
            _lowerCAmelCase					=				n_positions
            _lowerCAmelCase					=				n_embd
            _lowerCAmelCase					=				n_layer
            _lowerCAmelCase					=				n_head
            _lowerCAmelCase					=				n_inner
            _lowerCAmelCase					=				rotary_dim
            _lowerCAmelCase					=				activation_function
            _lowerCAmelCase					=				resid_pdrop
            _lowerCAmelCase					=				embd_pdrop
            _lowerCAmelCase					=				attn_pdrop
            _lowerCAmelCase					=				layer_norm_epsilon
            _lowerCAmelCase					=				initializer_range
            _lowerCAmelCase					=				use_cache

            _lowerCAmelCase					=				bos_token_id
            _lowerCAmelCase					=				eos_token_id

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




class 					UpperCAmelCase	(     snake_case_  ):




      def __init__(     self     :					List[Any]     ,     __snake_case     :					PretrainedConfig     ,     __snake_case     :					str = "default"     ,     __snake_case     :					List[PatchingSpec] = None     ,     __snake_case     :					bool = False     ,     )							-> Optional[int]:
            super().__init__(__snake_case     ,     task=__snake_case     ,     patching_specs=__snake_case     ,     use_past=__snake_case    )
            if not getattr(self._config     ,     """pad_token_id"""     ,     __snake_case    ):
                  # TODO: how to do that better?
                  _lowerCAmelCase					=				0




      @property
      def 							lowercase__       (     self     :					Optional[Any]    )							-> Mapping[str, Mapping[int, str]]:
            _lowerCAmelCase					=				OrderedDict({"""input_ids""": {0: """batch""", 1: """sequence"""}}    )
            if self.use_past:
                  self.fill_with_past_key_values_(__snake_case     ,     direction="""inputs"""    )
                  _lowerCAmelCase					=				{0: """batch""", 1: """past_sequence + sequence"""}
            else:
                  _lowerCAmelCase					=				{0: """batch""", 1: """sequence"""}

            return common_inputs




      @property
      def 							lowercase__       (     self     :					List[Any]    )							-> int:
            return self._config.n_layer




      @property
      def 							lowercase__       (     self     :					int    )							-> int:
            return self._config.n_head




      def 							lowercase__       (     self     :					List[Any]     ,     __snake_case     :					PreTrainedTokenizer     ,     __snake_case     :					int = -1     ,     __snake_case     :					int = -1     ,     __snake_case     :					bool = False     ,     __snake_case     :					Optional[TensorType] = None     ,     )							-> Mapping[str, Any]:
            _lowerCAmelCase					=				super(__snake_case     ,     self    ).generate_dummy_inputs(
                __snake_case     ,     batch_size=__snake_case     ,     seq_length=__snake_case     ,     is_pair=__snake_case     ,     framework=__snake_case    )

            # We need to order the input in the way they appears in the forward()
            _lowerCAmelCase					=				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

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

            _lowerCAmelCase					=				common_inputs["""attention_mask"""]
            if self.use_past:
                  _lowerCAmelCase					=				ordered_inputs["""attention_mask"""].dtype
                  _lowerCAmelCase					=				torch.cat(
                      [ordered_inputs["""attention_mask"""], torch.ones(__snake_case     ,     __snake_case     ,     dtype=__snake_case    )]     ,     dim=1    )

            return ordered_inputs




      @property
      def 							lowercase__       (     self     :					Optional[Any]    )							-> int:
            return 13













'''simple docstring'''






def   UpperCamelCase__ (						lowerCAmelCase    ):





      """simple docstring"""


      if divisor % 5 == 0 or divisor % 2 == 0:
            return 0
      _lowerCAmelCase					=				1
      _lowerCAmelCase					=				1
      while repunit:
            _lowerCAmelCase					=				(10 * repunit + 1) % divisor
            repunit_index += 1
      return repunit_index
def   UpperCamelCase__ (						lowerCAmelCase = 1_00_00_00    ):





      """simple docstring"""


      _lowerCAmelCase					=				limit - 1
      if divisor % 2 == 0:
            divisor += 1
      while least_divisible_repunit(lowerCAmelCase    ) <= limit:
            divisor += 2
      return divisor


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






