



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


__snake_case     :Any			       =logging.get_logger(__name__)

__snake_case     :List[Any]			       ={
    '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        lowerCAmelCase__					(  _lowerCamelCase       ):
				A_   :     int								=     'bloom'
				A_   :     Any								=     ['past_key_values']
				A_   :     Dict								=     {
				    'num_hidden_layers': 'n_layer',
				    'num_attention_heads': 'n_head',
				}


				def __init__(							self      :  Any						, __UpperCamelCase      :  Optional[int]=250_880						, __UpperCamelCase      :  List[str]=64						, __UpperCamelCase      :  Tuple=2						, __UpperCamelCase      :  Optional[int]=8						, __UpperCamelCase      :  str=1e-5						, __UpperCamelCase      :  Union[str, Any]=0.0_2						, __UpperCamelCase      :  Optional[Any]=True						, __UpperCamelCase      :  Union[str, Any]=1						, __UpperCamelCase      :  List[Any]=2						, __UpperCamelCase      :  Optional[int]=False						, __UpperCamelCase      :  List[Any]=0.0						, __UpperCamelCase      :  int=0.0						, __UpperCamelCase      :  Optional[Any]=1						, __UpperCamelCase      :  List[Any]=False						, **__UpperCamelCase      :  Dict						, )		->     Any:
											A      						=    vocab_size
											# Backward compatibility with n_embed kwarg
											A      						=    kwargs.pop('n_embed'						, __UpperCamelCase       )
											A      						=    hidden_size if n_embed is None else n_embed
											A      						=    n_layer
											A      						=    n_head
											A      						=    layer_norm_epsilon
											A      						=    initializer_range
											A      						=    use_cache
											A      						=    pretraining_tp
											A      						=    apply_residual_connection_post_layernorm
											A      						=    hidden_dropout
											A      						=    attention_dropout

											A      						=    bos_token_id
											A      						=    eos_token_id
											A      						=    slow_but_exact

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





class        lowerCAmelCase__					(  _lowerCamelCase       ):
				A_   :     str								=     version.parse('1.12'       )


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


				@property
				def __UpperCamelCase						(							self      :  Union[str, Any]       )		->     Mapping[str, Mapping[int, str]]:
											A      						=    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_(__UpperCamelCase						, direction='inputs'						, inverted_values_shape=__UpperCamelCase       )
																		A      						=    {0: 'batch', 1: 'past_sequence + sequence'}
											else:
																		A      						=    {0: 'batch', 1: 'sequence'}

											return common_inputs


				@property
				def __UpperCamelCase						(							self      :  int       )		->     int:
											return self._config.n_layer


				@property
				def __UpperCamelCase						(							self      :  Union[str, Any]       )		->     int:
											return self._config.n_head


				@property
				def __UpperCamelCase						(							self      :  str       )		->     float:
											return 1e-3


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

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

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

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

											return ordered_inputs


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




'''simple docstring'''





def lowerCAmelCase    (__A):



     """simple docstring"""



     return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6'''))




def lowerCAmelCase    (__A):



     """simple docstring"""



     _a           =    credit_card_number
     _a           =    0
     _a           =    len(__A) - 2
     for i in range(__A    ,      -1    ,      -2):
          #  double the value of every second digit
          _a           =    int(cc_number[i])
          digit *= 2
          # If doubling of a number results in a two digit number
          # i.e greater than 9(e.g., 6 × 2 = 12),
          # then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
          # to get a single digit number.
          if digit > 9:
               digit %= 10
               digit += 1
          _a           =    cc_number[:i] + str(__A) + cc_number[i + 1 :]
          total += digit

     # Sum up the remaining digits
     for i in range(len(__A) - 1    ,      -1    ,      -2):
          total += int(cc_number[i])

     return total % 10 == 0




def lowerCAmelCase    (__A):



     """simple docstring"""



     _a           =    F'''{credit_card_number} is an invalid credit card number because'''
     if not credit_card_number.isdigit():
          print(F'''{error_message} it has nonnumerical characters.''')
          return False

     if not 13 <= len(__A) <= 16:
          print(F'''{error_message} of its length.''')
          return False

     if not validate_initial_digits(__A):
          print(F'''{error_message} of its first two digits.''')
          return False

     if not luhn_validation(__A):
          print(F'''{error_message} it fails the Luhn check.''')
          return False

     print(F'''{credit_card_number} is a valid credit card number.''')
     return True


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  validate_credit_card_number("4111111111111111")
  validate_credit_card_number("32323")



