


import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        FalconForCausalLM,
        FalconForQuestionAnswering,
        FalconForSequenceClassification,
        FalconForTokenClassification,
        FalconModel,
    )



class 							_UpperCamelCase :

   '''simple docstring'''







   def __init__(  self  : List[str]       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : Tuple=3       ,  _lowerCamelCase  : str=7       ,  _lowerCamelCase  : List[Any]=True       ,  _lowerCamelCase  : List[Any]=True       ,  _lowerCamelCase  : Tuple=False       ,  _lowerCamelCase  : int=True       ,  _lowerCamelCase  : Tuple=9_9       ,  _lowerCamelCase  : Union[str, Any]=3_2       ,  _lowerCamelCase  : Optional[Any]=5       ,  _lowerCamelCase  : Union[str, Any]=4       ,  _lowerCamelCase  : Tuple=3_7       ,  _lowerCamelCase  : Any="gelu"       ,  _lowerCamelCase  : Any=0.1       ,  _lowerCamelCase  : Optional[int]=0.1       ,  _lowerCamelCase  : Tuple=5_1_2       ,  _lowerCamelCase  : Optional[int]=1_6       ,  _lowerCamelCase  : List[str]=2       ,  _lowerCamelCase  : Optional[Any]=0.02       ,  _lowerCamelCase  : List[Any]=3       ,  _lowerCamelCase  : Optional[Any]=4       ,  _lowerCamelCase  : str=None       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						parent
         __lowerCamelCase     :      List[str]       						=						batch_size
         __lowerCamelCase     :      Optional[Any]       						=						seq_length
         __lowerCamelCase     :      List[str]       						=						is_training
         __lowerCamelCase     :      List[Any]       						=						use_input_mask
         __lowerCamelCase     :      Optional[Any]       						=						use_token_type_ids
         __lowerCamelCase     :      List[Any]       						=						use_labels
         __lowerCamelCase     :      Dict       						=						vocab_size
         __lowerCamelCase     :      Dict       						=						hidden_size
         __lowerCamelCase     :      List[Any]       						=						num_hidden_layers
         __lowerCamelCase     :      Dict       						=						num_attention_heads
         __lowerCamelCase     :      Any       						=						intermediate_size
         __lowerCamelCase     :      Optional[int]       						=						hidden_act
         __lowerCamelCase     :      List[Any]       						=						hidden_dropout_prob
         __lowerCamelCase     :      Any       						=						attention_probs_dropout_prob
         __lowerCamelCase     :      str       						=						max_position_embeddings
         __lowerCamelCase     :      Any       						=						type_vocab_size
         __lowerCamelCase     :      str       						=						type_sequence_label_size
         __lowerCamelCase     :      Optional[int]       						=						initializer_range
         __lowerCamelCase     :      Union[str, Any]       						=						num_labels
         __lowerCamelCase     :      Tuple       						=						num_choices
         __lowerCamelCase     :      int       						=						scope

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						ids_tensor([self.batch_size, self.seq_length]       ,  self.vocab_size							)

         __lowerCamelCase     :      List[str]       						=						None
         if self.use_input_mask:
               __lowerCamelCase     :      Union[str, Any]       						=						random_attention_mask([self.batch_size, self.seq_length]							)

         __lowerCamelCase     :      List[str]       						=						None

         __lowerCamelCase     :      Union[str, Any]       						=						None
         __lowerCamelCase     :      Tuple       						=						None
         __lowerCamelCase     :      Dict       						=						None
         if self.use_labels:
               __lowerCamelCase     :      Optional[int]       						=						ids_tensor([self.batch_size]       ,  self.type_sequence_label_size							)
               __lowerCamelCase     :      Any       						=						ids_tensor([self.batch_size, self.seq_length]       ,  self.num_labels							)
               __lowerCamelCase     :      Dict       						=						ids_tensor([self.batch_size]       ,  self.num_choices							)

         __lowerCamelCase     :      Union[str, Any]       						=						self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels

   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         return FalconConfig(
             vocab_size=self.vocab_size       ,  hidden_size=self.hidden_size       ,  num_hidden_layers=self.num_hidden_layers       ,  num_attention_heads=self.num_attention_heads       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  hidden_dropout_prob=self.hidden_dropout_prob       ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,  max_position_embeddings=self.max_position_embeddings       ,  type_vocab_size=self.type_vocab_size       ,  is_decoder=_lowerCamelCase       ,  initializer_range=self.initializer_range       ,  pad_token_id=1       ,  new_decoder_architecture=_lowerCamelCase       ,  )

   def   _snake_case    (  self  : Tuple       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Dict       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : int							):






         '''simple docstring'''



         __lowerCamelCase     :      Any       						=						FalconModel(config=_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      List[Any]       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase							)
         __lowerCamelCase     :      int       						=						model(_lowerCamelCase							)
         self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)							)

   def   _snake_case    (  self  : Optional[Any]       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : List[Any]       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      int       						=						True
         __lowerCamelCase     :      Optional[Any]       						=						FalconModel(_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      List[Any]       						=						model(
             _lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  encoder_hidden_states=_lowerCamelCase       ,  encoder_attention_mask=_lowerCamelCase       ,  )
         __lowerCamelCase     :      str       						=						model(
             _lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  encoder_hidden_states=_lowerCamelCase       ,  )
         __lowerCamelCase     :      Dict       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase							)
         self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)							)

   def   _snake_case    (  self  : int       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Dict       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      Tuple       						=						FalconForCausalLM(config=_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      int       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  labels=_lowerCamelCase							)
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.vocab_size)							)

   def   _snake_case    (  self  : Union[str, Any]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : List[str]       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						True
         __lowerCamelCase     :      List[str]       						=						True
         __lowerCamelCase     :      Dict       						=						FalconForCausalLM(config=_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()

         # first forward pass
         __lowerCamelCase     :      Optional[Any]       						=						model(
             _lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  encoder_hidden_states=_lowerCamelCase       ,  encoder_attention_mask=_lowerCamelCase       ,  use_cache=_lowerCamelCase       ,  )
         __lowerCamelCase     :      Optional[int]       						=						outputs.past_key_values

         # create hypothetical multiple next token and extent to next_input_ids
         __lowerCamelCase     :      int       						=						ids_tensor((self.batch_size, 3)       ,  config.vocab_size							)
         __lowerCamelCase     :      List[str]       						=						ids_tensor((self.batch_size, 3)       ,  vocab_size=2							)

         # append to next input_ids and
         __lowerCamelCase     :      List[str]       						=						torch.cat([input_ids, next_tokens]       ,  dim=-1							)
         __lowerCamelCase     :      Any       						=						torch.cat([input_mask, next_mask]       ,  dim=-1							)

         __lowerCamelCase     :      Any       						=						model(
             _lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  encoder_hidden_states=_lowerCamelCase       ,  encoder_attention_mask=_lowerCamelCase       ,  output_hidden_states=_lowerCamelCase       ,  )["""hidden_states"""][0]
         __lowerCamelCase     :      Tuple       						=						model(
             _lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  encoder_hidden_states=_lowerCamelCase       ,  encoder_attention_mask=_lowerCamelCase       ,  past_key_values=_lowerCamelCase       ,  output_hidden_states=_lowerCamelCase       ,  )["""hidden_states"""][0]

         # select random slice
         __lowerCamelCase     :      Tuple       						=						ids_tensor((1,)       ,  output_from_past.shape[-1]							).item()
         __lowerCamelCase     :      List[str]       						=						output_from_no_past[:, -3:, random_slice_idx].detach()
         __lowerCamelCase     :      Any       						=						output_from_past[:, :, random_slice_idx].detach()

         self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]							)

         # test that outputs are equal for slice
         self.parent.assertTrue(torch.allclose(_lowerCamelCase       ,  _lowerCamelCase       ,  atol=1E-3							)							)


   def   _snake_case    (  self  : List[Any]							):






         '''simple docstring'''



         __lowerCamelCase     :      Optional[Any]       						=						self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, (
             __lowerCamelCase
         )						, 
         )     :      str       						=						config_and_inputs
         __lowerCamelCase     :      List[Any]       						=						{"""input_ids""": input_ids, """attention_mask""": input_mask}
         return config, inputs_dict



@require_torch
class 							_UpperCamelCase (						A,A,A,unittest.TestCase						):

   '''simple docstring'''







   a_				:							Tuple    = (
       (
           FalconModel,
           FalconForCausalLM,
           FalconForSequenceClassification,
           FalconForTokenClassification,
           FalconForQuestionAnswering,
       )
       if is_torch_available()
       else ()
   )
   a_				:							Union[str, Any]    = (FalconForCausalLM,) if is_torch_available() else ()
   a_				:							Any    = (
       {
           "feature-extraction": FalconModel,
           "text-classification": FalconForSequenceClassification,
           "text-generation": FalconForCausalLM,
           "question-answering": FalconForQuestionAnswering,
           "token-classification": FalconForTokenClassification,
           "zero-shot": FalconForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   a_				:							List[Any]    = False
   a_				:							int    = False

   def   _snake_case    (  self  : List[Any]							):






         '''simple docstring'''



         __lowerCamelCase     :      Optional[Any]       						=						FalconModelTester(self							)
         __lowerCamelCase     :      Tuple       						=						ConfigTester(self       ,  config_class=_lowerCamelCase       ,  hidden_size=3_7							)

   def   _snake_case    (  self  : List[str]							):






         '''simple docstring'''



         self.config_tester.run_common_tests()

   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         __lowerCamelCase     :      Any       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*_lowerCamelCase							)

   def   _snake_case    (  self  : Optional[Any]							):






         '''simple docstring'''



         __lowerCamelCase						, *__lowerCamelCase     :      Optional[int]       						=						self.model_tester.prepare_config_and_inputs()
         for alibi in [True, False]:
               __lowerCamelCase     :      List[str]       						=						alibi
               self.model_tester.create_and_check_model(_lowerCamelCase       ,  *_lowerCamelCase							)

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         __lowerCamelCase						, __lowerCamelCase     :      Optional[int]       						=						self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase     :      Tuple       						=						3
         __lowerCamelCase     :      List[str]       						=						input_dict["""input_ids"""]
         __lowerCamelCase     :      Dict       						=						input_ids.ne(1							).to(_lowerCamelCase							)
         __lowerCamelCase     :      str       						=						ids_tensor([self.model_tester.batch_size]       ,  self.model_tester.type_sequence_label_size							)
         __lowerCamelCase     :      Optional[int]       						=						FalconForSequenceClassification(_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      Any       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  labels=_lowerCamelCase							)
         self.assertEqual(result.logits.shape       ,  (self.model_tester.batch_size, self.model_tester.num_labels)							)

   def   _snake_case    (  self  : Dict							):






         '''simple docstring'''



         __lowerCamelCase						, __lowerCamelCase     :      Dict       						=						self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase     :      Tuple       						=						3
         __lowerCamelCase     :      Any       						=						"""single_label_classification"""
         __lowerCamelCase     :      Tuple       						=						input_dict["""input_ids"""]
         __lowerCamelCase     :      Dict       						=						input_ids.ne(1							).to(_lowerCamelCase							)
         __lowerCamelCase     :      Tuple       						=						ids_tensor([self.model_tester.batch_size]       ,  self.model_tester.type_sequence_label_size							)
         __lowerCamelCase     :      Tuple       						=						FalconForSequenceClassification(_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      Dict       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  labels=_lowerCamelCase							)
         self.assertEqual(result.logits.shape       ,  (self.model_tester.batch_size, self.model_tester.num_labels)							)

   def   _snake_case    (  self  : str							):






         '''simple docstring'''



         __lowerCamelCase						, __lowerCamelCase     :      Optional[Any]       						=						self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase     :      Tuple       						=						input_dict["""input_ids"""]
         __lowerCamelCase     :      Optional[int]       						=						FalconForCausalLM(_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      Dict       						=						model(_lowerCamelCase       ,  use_cache=_lowerCamelCase							)
         __lowerCamelCase     :      List[str]       						=						input_ids.shape[0]
         __lowerCamelCase     :      Any       						=						model._convert_to_rw_cache(result.past_key_values							)
         __lowerCamelCase     :      Dict       						=						model._convert_cache_to_standard_format(_lowerCamelCase       ,  _lowerCamelCase							)
         for layer in range(len(_lowerCamelCase							)							):
               for tensor_idx in range(2							):
                     self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3							)
                     self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4							)
                     self.assertTrue(
                         torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]							)							)

   def   _snake_case    (  self  : Union[str, Any]							):






         '''simple docstring'''



         __lowerCamelCase						, __lowerCamelCase     :      Any       						=						self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase     :      Optional[int]       						=						3
         __lowerCamelCase     :      Optional[int]       						=						"""multi_label_classification"""
         __lowerCamelCase     :      Optional[int]       						=						input_dict["""input_ids"""]
         __lowerCamelCase     :      Any       						=						input_ids.ne(1							).to(_lowerCamelCase							)
         __lowerCamelCase     :      Dict       						=						ids_tensor(
             [self.model_tester.batch_size, config.num_labels]       ,  self.model_tester.type_sequence_label_size							).to(torch.float							)
         __lowerCamelCase     :      Tuple       						=						FalconForSequenceClassification(_lowerCamelCase							)
         model.to(_lowerCamelCase							)
         model.eval()
         __lowerCamelCase     :      List[str]       						=						model(_lowerCamelCase       ,  attention_mask=_lowerCamelCase       ,  labels=_lowerCamelCase							)
         self.assertEqual(result.logits.shape       ,  (self.model_tester.batch_size, self.model_tester.num_labels)							)


   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         for model_class in self.all_generative_model_classes:
               __lowerCamelCase						, __lowerCamelCase     :      Any       						=						self.model_tester.prepare_config_and_inputs_for_common()

               # If it doesn't support cache, pass the test
               if not hasattr(_lowerCamelCase       ,  """use_cache"""							):
                     return

               __lowerCamelCase     :      Tuple       						=						model_class(_lowerCamelCase							).to(_lowerCamelCase							)
               if "use_cache" not in inputs:
                     __lowerCamelCase     :      Optional[int]       						=						True
               __lowerCamelCase     :      Any       						=						model(**_lowerCamelCase							)

               # If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
               if "past_key_values" not in outputs:
                     return

               __lowerCamelCase     :      Tuple       						=						(
                   getattr(_lowerCamelCase       ,  """decoder_layers"""       ,  _lowerCamelCase							)
                   or getattr(_lowerCamelCase       ,  """num_decoder_layers"""       ,  _lowerCamelCase							)
                   or config.num_hidden_layers
               )
               __lowerCamelCase     :      str       						=						getattr(_lowerCamelCase       ,  """num_kv_heads"""       ,  config.num_attention_heads							)
               __lowerCamelCase     :      Dict       						=						getattr(_lowerCamelCase       ,  """d_model"""       ,  config.hidden_size							)
               __lowerCamelCase     :      Any       						=						embed_dim // num_attention_heads

               __lowerCamelCase     :      int       						=						outputs["""past_key_values"""]
               self.assertEqual(len(_lowerCamelCase							)       ,  _lowerCamelCase							)

               __lowerCamelCase						, __lowerCamelCase     :      Optional[Any]       						=						inputs["""input_ids"""].shape
               for i in range(_lowerCamelCase							):
                     if config.new_decoder_architecture:
                           __lowerCamelCase     :      Any       						=						config.num_attention_heads
                     elif config.multi_query:
                           __lowerCamelCase     :      int       						=						1
                     self.assertEqual(len(past_kv[0]							)       ,  2							)  # K V for the decoder = 2
                     self.assertEqual(
                         past_kv[i][0].shape       ,  (batch_size, num_attention_heads, seq_length, per_head_embed_dim)							)
                     self.assertEqual(
                         past_kv[i][1].shape       ,  (batch_size, num_attention_heads, seq_length, per_head_embed_dim)							)



@require_torch
class 							_UpperCamelCase (						unittest.TestCase						):

   '''simple docstring'''







   @slow
   def   _snake_case    (  self  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      List[Any]       						=						AutoTokenizer.from_pretrained("""Rocketknight1/falcon-rw-1b"""							)
         __lowerCamelCase     :      List[str]       						=						FalconForCausalLM.from_pretrained("""Rocketknight1/falcon-rw-1b"""							)
         model.eval()
         model.to(_lowerCamelCase							)
         __lowerCamelCase     :      Optional[int]       						=						tokenizer("""My favorite food is"""       ,  return_tensors="""pt"""							).to(_lowerCamelCase							)

         __lowerCamelCase     :      int       						=						(
             """My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday."""
         )

         __lowerCamelCase     :      Dict       						=						model.generate(**_lowerCamelCase       ,  do_sample=_lowerCamelCase       ,  max_new_tokens=1_9							)
         __lowerCamelCase     :      Union[str, Any]       						=						tokenizer.batch_decode(_lowerCamelCase							)[0]

         self.assertEqual(_lowerCamelCase       ,  _lowerCamelCase							)

   @slow
   def   _snake_case    (  self  : Union[str, Any]							):






         '''simple docstring'''



         for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
               __lowerCamelCase     :      int       						=						AutoTokenizer.from_pretrained(_lowerCamelCase							)
               __lowerCamelCase     :      Dict       						=						FalconForCausalLM.from_pretrained(_lowerCamelCase							)
               model.eval()
               model.to(_lowerCamelCase							)
               __lowerCamelCase     :      Tuple       						=						tokenizer("""My favorite food is"""       ,  return_tensors="""pt"""							).to(_lowerCamelCase							)

               # We just test that these run without errors - the models are randomly initialized
               # and so the actual text outputs will be garbage
               model.generate(**_lowerCamelCase       ,  do_sample=_lowerCamelCase       ,  max_new_tokens=4							)
               model.generate(**_lowerCamelCase       ,  do_sample=_lowerCamelCase       ,  max_new_tokens=4							)
               model.generate(**_lowerCamelCase       ,  num_beams=2       ,  max_new_tokens=4							)


   @slow
   def   _snake_case    (  self  : List[str]							):






         '''simple docstring'''



         with torch.no_grad():
               for repo in [
                   "Rocketknight1/falcon-rw-1b",
                   "Rocketknight1/tiny-random-falcon-7b",
                   "Rocketknight1/tiny-random-falcon-40b",
               ]:
                     __lowerCamelCase     :      Any       						=						AutoTokenizer.from_pretrained(_lowerCamelCase							)
                     __lowerCamelCase     :      Dict       						=						FalconForCausalLM.from_pretrained(_lowerCamelCase							)
                     model.eval()
                     model.to(device=_lowerCamelCase							)
                     __lowerCamelCase     :      str       						=						tokenizer("""My favorite food is"""       ,  return_tensors="""pt"""							).to(_lowerCamelCase							)

                     # Test results are the same with and without cache
                     __lowerCamelCase     :      Optional[Any]       						=						model.generate(**_lowerCamelCase       ,  do_sample=_lowerCamelCase       ,  max_new_tokens=2_0       ,  use_cache=_lowerCamelCase							)
                     __lowerCamelCase     :      Any       						=						model.generate(**_lowerCamelCase       ,  do_sample=_lowerCamelCase       ,  max_new_tokens=2_0       ,  use_cache=_lowerCamelCase							)
                     self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0							)







def   _UpperCAmelCase       (     ):
      """simple docstring"""




      __lowerCamelCase     :      Optional[int]       						=						[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

      __lowerCamelCase     :      str       						=						6
      __lowerCamelCase     :      Optional[int]       						=						1
      __lowerCamelCase     :      Optional[int]       						=						1_901

      __lowerCamelCase     :      Optional[Any]       						=						0

      while year < 2_001:
            day += 7

            if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
                  if day > days_per_month[month - 1] and month != 2:
                        month += 1
                        __lowerCamelCase     :      Tuple       						=						day - days_per_month[month - 2]
                  elif day > 29 and month == 2:
                        month += 1
                        __lowerCamelCase     :      str       						=						day - 29
            else:
                  if day > days_per_month[month - 1]:
                        month += 1
                        __lowerCamelCase     :      Any       						=						day - days_per_month[month - 2]

            if month > 12:
                  year += 1
                  __lowerCamelCase     :      Optional[Any]       						=						1

            if year < 2_001 and day == 1:
                  sundays += 1
      return sundays


if __name__ == "__main__":
    print(solution())



