





"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional

from packaging import version


if TYPE_CHECKING:
  from ... import PreTrainedTokenizer, TensorType

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


lowerCamelCase_       =		logging.get_logger(__name__)

lowerCamelCase_       =		{
    "bigscience/bloom": "https://huggingface.co/bigscience/bloom/resolve/main/config.json",
    "bigscience/bloom-560m": "https://huggingface.co/bigscience/bloom-560m/blob/main/config.json",
    "bigscience/bloom-1b1": "https://huggingface.co/bigscience/bloom-1b1/blob/main/config.json",
    "bigscience/bloom-1b7": "https://huggingface.co/bigscience/bloom-1b7/blob/main/config.json",
    "bigscience/bloom-3b": "https://huggingface.co/bigscience/bloom-3b/blob/main/config.json",
    "bigscience/bloom-7b1": "https://huggingface.co/bigscience/bloom-7b1/blob/main/config.json",
}






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				List[Any]     						=  '''bloom'''
       SCREAMING_SNAKE_CASE_       :				Dict     						=  ['''past_key_values''']
       SCREAMING_SNAKE_CASE_       :				Optional[Any]     						=  {
           '''num_hidden_layers''': '''n_layer''',
           '''num_attention_heads''': '''n_head''',
       }




       def __init__(						self		,SCREAMING_SNAKE_CASE__=25_08_80		,SCREAMING_SNAKE_CASE__=64		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=8		,SCREAMING_SNAKE_CASE__=1E-5		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=False		,**SCREAMING_SNAKE_CASE__		,)      ->				List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Any		    =  vocab_size
             # Backward compatibility with n_embed kwarg
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  kwargs.pop('''n_embed'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :List[str]		    =  hidden_size if n_embed is None else n_embed
             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  n_layer
             __SCREAMING_SNAKE_CASE       :int		    =  n_head
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  layer_norm_epsilon
             __SCREAMING_SNAKE_CASE       :Dict		    =  initializer_range
             __SCREAMING_SNAKE_CASE       :int		    =  use_cache
             __SCREAMING_SNAKE_CASE       :Tuple		    =  pretraining_tp
             __SCREAMING_SNAKE_CASE       :str		    =  apply_residual_connection_post_layernorm
             __SCREAMING_SNAKE_CASE       :Dict		    =  hidden_dropout
             __SCREAMING_SNAKE_CASE       :str		    =  attention_dropout

             __SCREAMING_SNAKE_CASE       :str		    =  bos_token_id
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  eos_token_id
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  slow_but_exact

             super().__init__(bos_token_id=SCREAMING_SNAKE_CASE__		,eos_token_id=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				str     						=  version.parse('''1.12'''  )




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = "default"		,SCREAMING_SNAKE_CASE__ = None		,SCREAMING_SNAKE_CASE__ = False		,)      ->				Any:





             """simple docstring"""






             super().__init__(SCREAMING_SNAKE_CASE__		,task=SCREAMING_SNAKE_CASE__		,patching_specs=SCREAMING_SNAKE_CASE__		,use_past=SCREAMING_SNAKE_CASE__							)
             if not getattr(self._config		,'''pad_token_id'''		,SCREAMING_SNAKE_CASE__							):
                   # TODO: how to do that better?
                   __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  0




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  OrderedDict({'''input_ids''': {0: '''batch''', 1: '''sequence'''}}							)
             if self.use_past:
                   # BLOOM stores values on dynamic axis 2. For more details see: https://github.com/huggingface/transformers/pull/18344
                   self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE__		,direction='''inputs'''		,inverted_values_shape=SCREAMING_SNAKE_CASE__							)
                   __SCREAMING_SNAKE_CASE       :Dict		    =  {0: '''batch''', 1: '''past_sequence + sequence'''}
             else:
                   __SCREAMING_SNAKE_CASE       :Any		    =  {0: '''batch''', 1: '''sequence'''}

             return common_inputs




       @property
       def    _UpperCamelCase					(						self							)      ->				int:





             """simple docstring"""






             return self._config.n_layer




       @property
       def    _UpperCamelCase					(						self							)      ->				int:





             """simple docstring"""






             return self._config.n_head




       @property
       def    _UpperCamelCase					(						self							)      ->				float:





             """simple docstring"""






             return 1E-3




       def    _UpperCamelCase					(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = -1		,SCREAMING_SNAKE_CASE__ = -1		,SCREAMING_SNAKE_CASE__ = False		,SCREAMING_SNAKE_CASE__ = None		,)      ->				Mapping[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Dict		    =  super(SCREAMING_SNAKE_CASE__		,self							).generate_dummy_inputs(
                 SCREAMING_SNAKE_CASE__		,batch_size=SCREAMING_SNAKE_CASE__		,seq_length=SCREAMING_SNAKE_CASE__		,is_pair=SCREAMING_SNAKE_CASE__		,framework=SCREAMING_SNAKE_CASE__							)

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

                         __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :Any		    =  common_inputs['''input_ids'''].shape
                         # Not using the same length for past_key_values
                         __SCREAMING_SNAKE_CASE       :List[str]		    =  seqlen + 2
                         __SCREAMING_SNAKE_CASE       :Optional[int]		    =  self._config.hidden_size // self.num_attention_heads
                         __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  (
                             batch * self.num_attention_heads,
                             head_dim,
                             past_key_values_length,
                         )
                         __SCREAMING_SNAKE_CASE       :Dict		    =  (
                             batch * self.num_attention_heads,
                             past_key_values_length,
                             head_dim,
                         )
                         __SCREAMING_SNAKE_CASE       :Tuple		    =  [
                             (torch.zeros(SCREAMING_SNAKE_CASE__							), torch.zeros(SCREAMING_SNAKE_CASE__							)) for _ in range(self.num_layers							)
                         ]

             __SCREAMING_SNAKE_CASE       :List[Any]		    =  common_inputs['''attention_mask''']
             if self.use_past:
                   __SCREAMING_SNAKE_CASE       :List[Any]		    =  ordered_inputs['''attention_mask'''].dtype
                   __SCREAMING_SNAKE_CASE       :str		    =  torch.cat(
                       [ordered_inputs['''attention_mask'''], torch.ones(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,dtype=SCREAMING_SNAKE_CASE__							)]		,dim=1							)

             return ordered_inputs




       @property
       def    _UpperCamelCase					(						self							)      ->				int:





             """simple docstring"""






             return 13






"""simple docstring"""
import math
import unittest



def 					__lowerCamelCase       (							a_					:		int							)      ->				bool:
      assert isinstance(a_			,       a_							) and (
          number >= 0
      ), "'number' must been an int and positive"

      if 1 < number < 4:
            # 2 and 3 are primes
            return True
      elif number < 2 or number % 2 == 0 or number % 3 == 0:
            # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
            return False

      # All primes number are in format of 6k +/- 1
      for i in range(5			,       int(math.sqrt(a_							) + 1							)			,       6							):
            if number % i == 0 or number % (i + 2) == 0:
                  return False
      return True






class  _SCREAMING_SNAKE_CASE(       unittest.TestCase  ):




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





             """simple docstring"""






             self.assertTrue(is_prime(2							)							)
             self.assertTrue(is_prime(3							)							)
             self.assertTrue(is_prime(5							)							)
             self.assertTrue(is_prime(7							)							)
             self.assertTrue(is_prime(11							)							)
             self.assertTrue(is_prime(13							)							)
             self.assertTrue(is_prime(17							)							)
             self.assertTrue(is_prime(19							)							)
             self.assertTrue(is_prime(23							)							)
             self.assertTrue(is_prime(29							)							)




       def    _UpperCamelCase					(						self							)      ->				Tuple:





             """simple docstring"""






             with self.assertRaises(SCREAMING_SNAKE_CASE__							):
                   is_prime(-19							)
             self.assertFalse(
                 is_prime(0							)		,'''Zero doesn\'t have any positive factors, primes must have exactly two.'''		,)
             self.assertFalse(
                 is_prime(1							)		,'''One only has 1 positive factor, primes must have exactly two.'''		,)
             self.assertFalse(is_prime(2 * 2							)							)
             self.assertFalse(is_prime(2 * 3							)							)
             self.assertFalse(is_prime(3 * 3							)							)
             self.assertFalse(is_prime(3 * 5							)							)
             self.assertFalse(is_prime(3 * 5 * 7							)							)


if __name__ == "__main__":
  unittest.main()