
'''simple docstring'''





import unittest

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

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import (
         RemBertConfig,
         RemBertForCausalLM,
         RemBertForMaskedLM,
         RemBertForMultipleChoice,
         RemBertForQuestionAnswering,
         RemBertForSequenceClassification,
         RemBertForTokenClassification,
         RemBertModel,
     )
     from transformers.models.rembert.modeling_rembert import REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST



class 			lowerCAmelCase__ :



  '''simple docstring'''






  def __init__(self	:			List[Any]						,			lowerCAmelCase_	:			Tuple						,			lowerCAmelCase_	:			Dict=13						,			lowerCAmelCase_	:			int=7						,			lowerCAmelCase_	:			List[Any]=True						,			lowerCAmelCase_	:			Optional[int]=True						,			lowerCAmelCase_	:			Tuple=True						,			lowerCAmelCase_	:			List[Any]=True						,			lowerCAmelCase_	:			Any=99						,			lowerCAmelCase_	:			Optional[Any]=32						,			lowerCAmelCase_	:			Optional[int]=18						,			lowerCAmelCase_	:			int=43						,			lowerCAmelCase_	:			Tuple=5						,			lowerCAmelCase_	:			Tuple=4						,			lowerCAmelCase_	:			Union[str, Any]=37						,			lowerCAmelCase_	:			Optional[Any]="gelu"						,			lowerCAmelCase_	:			List[str]=0.1						,			lowerCAmelCase_	:			Optional[Any]=0.1						,			lowerCAmelCase_	:			Union[str, Any]=5_12						,			lowerCAmelCase_	:			Any=16						,			lowerCAmelCase_	:			int=2						,			lowerCAmelCase_	:			Optional[Any]=0.02						,			lowerCAmelCase_	:			Optional[int]=3						,			lowerCAmelCase_	:			Dict=4						,			lowerCAmelCase_	:			Optional[Any]=None						,			) ->							str:
        snake_case_    							=				parent
        snake_case_    							=				batch_size
        snake_case_    							=				seq_length
        snake_case_    							=				is_training
        snake_case_    							=				use_input_mask
        snake_case_    							=				use_token_type_ids
        snake_case_    							=				use_labels
        snake_case_    							=				vocab_size
        snake_case_    							=				hidden_size
        snake_case_    							=				input_embedding_size
        snake_case_    							=				output_embedding_size
        snake_case_    							=				num_hidden_layers
        snake_case_    							=				num_attention_heads
        snake_case_    							=				intermediate_size
        snake_case_    							=				hidden_act
        snake_case_    							=				hidden_dropout_prob
        snake_case_    							=				attention_probs_dropout_prob
        snake_case_    							=				max_position_embeddings
        snake_case_    							=				type_vocab_size
        snake_case_    							=				type_sequence_label_size
        snake_case_    							=				initializer_range
        snake_case_    							=				num_labels
        snake_case_    							=				num_choices
        snake_case_    							=				scope

  def 		_lowerCamelCase						(self	:			str     ) ->							List[Any]:
        snake_case_    							=				ids_tensor([self.batch_size, self.seq_length]						,			self.vocab_size     )

        snake_case_    							=				None
        if self.use_input_mask:
              snake_case_    							=				random_attention_mask([self.batch_size, self.seq_length]     )

        snake_case_    							=				None
        if self.use_token_type_ids:
              snake_case_    							=				ids_tensor([self.batch_size, self.seq_length]						,			self.type_vocab_size     )

        snake_case_    							=				None
        snake_case_    							=				None
        snake_case_    							=				None
        if self.use_labels:
              snake_case_    							=				ids_tensor([self.batch_size]						,			self.type_sequence_label_size     )
              snake_case_    							=				ids_tensor([self.batch_size, self.seq_length]						,			self.num_labels     )
              snake_case_    							=				ids_tensor([self.batch_size]						,			self.num_choices     )

        snake_case_    							=				RemBertConfig(
            vocab_size=self.vocab_size						,			hidden_size=self.hidden_size						,			input_embedding_size=self.input_embedding_size						,			output_embedding_size=self.output_embedding_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						,			)

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

  def 		_lowerCamelCase						(self	:			List[str]     ) ->							Dict:
        (
            (
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						
        )    							=				self.prepare_config_and_inputs()

        snake_case_    							=				True
        snake_case_    							=				floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
        snake_case_    							=				ids_tensor([self.batch_size, self.seq_length]						,			vocab_size=2     )

        return (
            config,
            input_ids,
            token_type_ids,
            input_mask,
            sequence_labels,
            token_labels,
            choice_labels,
            encoder_hidden_states,
            encoder_attention_mask,
        )

  def 		_lowerCamelCase						(self	:			Any						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			Any						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			List[str]     ) ->							Tuple:
        snake_case_    							=				RemBertModel(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_     )
        snake_case_    							=				model(lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_     )
        snake_case_    							=				model(lowerCAmelCase_     )
        self.parent.assertEqual(result.last_hidden_state.shape						,			(self.batch_size, self.seq_length, self.hidden_size)     )

  def 		_lowerCamelCase						(self	:			str						,			lowerCAmelCase_	:			Dict						,			lowerCAmelCase_	:			Tuple						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			Union[str, Any]						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			int						,			) ->							Optional[int]:
        snake_case_    							=				True
        snake_case_    							=				RemBertModel(lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			encoder_hidden_states=lowerCAmelCase_						,			encoder_attention_mask=lowerCAmelCase_						,			)
        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			encoder_hidden_states=lowerCAmelCase_						,			)
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_     )
        self.parent.assertEqual(result.last_hidden_state.shape						,			(self.batch_size, self.seq_length, self.hidden_size)     )

  def 		_lowerCamelCase						(self	:			Optional[Any]						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			Any						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			Any						,			lowerCAmelCase_	:			Tuple						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			List[Any]						,			) ->							Union[str, Any]:
        snake_case_    							=				RemBertForCausalLM(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			labels=lowerCAmelCase_     )
        self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.seq_length, self.vocab_size)     )

  def 		_lowerCamelCase						(self	:			Union[str, Any]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			Dict						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			Tuple						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			List[Any]     ) ->							str:
        snake_case_    							=				RemBertForMaskedLM(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			labels=lowerCAmelCase_     )
        self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.seq_length, self.vocab_size)     )

  def 		_lowerCamelCase						(self	:			Tuple						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			Dict						,			lowerCAmelCase_	:			Any						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			Any						,			) ->							Any:
        snake_case_    							=				True
        snake_case_    							=				True
        snake_case_    							=				RemBertForCausalLM(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()

        # first forward pass
        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			encoder_hidden_states=lowerCAmelCase_						,			encoder_attention_mask=lowerCAmelCase_						,			use_cache=lowerCAmelCase_						,			)
        snake_case_    							=				outputs.past_key_values

        # create hypothetical multiple next token and extent to next_input_ids
        snake_case_    							=				ids_tensor((self.batch_size, 3)						,			config.vocab_size     )
        snake_case_    							=				ids_tensor((self.batch_size, 3)						,			vocab_size=2     )

        # append to next input_ids and
        snake_case_    							=				torch.cat([input_ids, next_tokens]						,			dim=-1     )
        snake_case_    							=				torch.cat([input_mask, next_mask]						,			dim=-1     )

        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			encoder_hidden_states=lowerCAmelCase_						,			encoder_attention_mask=lowerCAmelCase_						,			output_hidden_states=lowerCAmelCase_						,			)["hidden_states"][0]
        snake_case_    							=				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
        snake_case_    							=				ids_tensor((1,)						,			output_from_past.shape[-1]     ).item()
        snake_case_    							=				output_from_no_past[:, -3:, random_slice_idx].detach()
        snake_case_    							=				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 		_lowerCamelCase						(self	:			Optional[int]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[Any]     ) ->							Optional[int]:
        snake_case_    							=				RemBertForQuestionAnswering(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			start_positions=lowerCAmelCase_						,			end_positions=lowerCAmelCase_						,			)
        self.parent.assertEqual(result.start_logits.shape						,			(self.batch_size, self.seq_length)     )
        self.parent.assertEqual(result.end_logits.shape						,			(self.batch_size, self.seq_length)     )

  def 		_lowerCamelCase						(self	:			Tuple						,			lowerCAmelCase_	:			int						,			lowerCAmelCase_	:			Dict						,			lowerCAmelCase_	:			Optional[Any]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			List[str]						,			lowerCAmelCase_	:			Dict     ) ->							Tuple:
        snake_case_    							=				self.num_labels
        snake_case_    							=				RemBertForSequenceClassification(lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			labels=lowerCAmelCase_     )
        self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.num_labels)     )

  def 		_lowerCamelCase						(self	:			List[str]						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			Union[str, Any]						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			Optional[int]						,			lowerCAmelCase_	:			Union[str, Any]						,			lowerCAmelCase_	:			Optional[Any]     ) ->							Any:
        snake_case_    							=				self.num_labels
        snake_case_    							=				RemBertForTokenClassification(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				model(lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			labels=lowerCAmelCase_     )
        self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.seq_length, self.num_labels)     )

  def 		_lowerCamelCase						(self	:			List[Any]						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			Tuple						,			lowerCAmelCase_	:			List[Any]						,			lowerCAmelCase_	:			Dict						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			str						,			lowerCAmelCase_	:			Optional[Any]     ) ->							int:
        snake_case_    							=				self.num_choices
        snake_case_    							=				RemBertForMultipleChoice(config=lowerCAmelCase_     )
        model.to(lowerCAmelCase_     )
        model.eval()
        snake_case_    							=				input_ids.unsqueeze(1     ).expand(-1						,			self.num_choices						,			-1     ).contiguous()
        snake_case_    							=				token_type_ids.unsqueeze(1     ).expand(-1						,			self.num_choices						,			-1     ).contiguous()
        snake_case_    							=				input_mask.unsqueeze(1     ).expand(-1						,			self.num_choices						,			-1     ).contiguous()
        snake_case_    							=				model(
            lowerCAmelCase_						,			attention_mask=lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			labels=lowerCAmelCase_						,			)
        self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.num_choices)     )


  def 		_lowerCamelCase						(self	:			List[str]     ) ->							Union[str, Any]:
        snake_case_    							=				self.prepare_config_and_inputs()
        (
            (
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						
        )    							=				config_and_inputs
        snake_case_    							=				{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
        return config, inputs_dict



@require_torch
class 			lowerCAmelCase__ (							UpperCamelCase       ,				UpperCamelCase       ,				unittest.TestCase							):



  '''simple docstring'''






  _UpperCamelCase							=			(
      (
          RemBertModel,
          RemBertForMaskedLM,
          RemBertForCausalLM,
          RemBertForMultipleChoice,
          RemBertForQuestionAnswering,
          RemBertForSequenceClassification,
          RemBertForTokenClassification,
      )
      if is_torch_available()
      else ()
  )
  _UpperCamelCase							=			(RemBertForCausalLM,) if is_torch_available() else ()
  _UpperCamelCase							=			(
      {
          'feature-extraction': RemBertModel,
          'fill-mask': RemBertForMaskedLM,
          'question-answering': RemBertForQuestionAnswering,
          'text-classification': RemBertForSequenceClassification,
          'text-generation': RemBertForCausalLM,
          'token-classification': RemBertForTokenClassification,
          'zero-shot': RemBertForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )

  def 		_lowerCamelCase						(self	:			int     ) ->							List[str]:
        snake_case_    							=				RemBertModelTester(self     )
        snake_case_    							=				ConfigTester(self						,			config_class=lowerCAmelCase_						,			hidden_size=37     )

  def 		_lowerCamelCase						(self	:			Dict     ) ->							List[Any]:
        self.config_tester.run_common_tests()

  def 		_lowerCamelCase						(self	:			str     ) ->							str:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			Dict     ) ->							Dict:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        for type in ["absolute", "relative_key", "relative_key_query"]:
              snake_case_    							=				type
              self.model_tester.create_and_check_model(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			Any     ) ->							List[str]:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			int     ) ->							List[Any]:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_multiple_choice(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			str     ) ->							str:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs_for_decoder()
        self.model_tester.create_and_check_decoder_model_past_large_inputs(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			List[str]     ) ->							str:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			List[Any]     ) ->							Dict:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			Any     ) ->							Optional[Any]:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			int     ) ->							Any:
        snake_case_    							=				self.model_tester.prepare_config_and_inputs_for_decoder()
        self.model_tester.create_and_check_model_as_decoder(*lowerCAmelCase_     )

  def 		_lowerCamelCase						(self	:			List[Any]     ) ->							List[Any]:
        # This regression test was failing with PyTorch < 1.3
        (
            (
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						(
            snake_case_
        )							,						
        )    							=				self.model_tester.prepare_config_and_inputs_for_decoder()

        snake_case_    							=				None

        self.model_tester.create_and_check_model_as_decoder(
            lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			)


  @slow
  def 		_lowerCamelCase						(self	:			int     ) ->							Tuple:
        for model_name in REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              snake_case_    							=				RemBertModel.from_pretrained(lowerCAmelCase_     )
              self.assertIsNotNone(lowerCAmelCase_     )



@require_torch
class 			lowerCAmelCase__ (							unittest.TestCase							):



  '''simple docstring'''






  @slow
  def 		_lowerCamelCase						(self	:			List[Any]     ) ->							Optional[Any]:
        # Test exact values at the last hidden layer
        snake_case_    							=				RemBertModel.from_pretrained("google/rembert"     )
        snake_case_    							=				torch.tensor([[3_12, 5_64_98, 3_13, 21_25, 3_13]]     )
        snake_case_    							=				torch.tensor([[0, 0, 0, 1, 1]]     )
        with torch.no_grad():
              snake_case_    							=				model(lowerCAmelCase_						,			token_type_ids=lowerCAmelCase_						,			output_hidden_states=lowerCAmelCase_     )

        snake_case_    							=				11_52

        snake_case_    							=				torch.Size((1, 5, hidden_size)     )
        self.assertEqual(output["last_hidden_state"].shape						,			lowerCAmelCase_     )

        snake_case_    							=				torch.tensor(
            [
                [
                    [0.0_754, -0.2_022, 0.1_904],
                    [-0.3_354, -0.3_692, -0.4_791],
                    [-0.2_314, -0.6_729, -0.0_749],
                    [-0.0_396, -0.3_105, -0.4_234],
                    [-0.1_571, -0.0_525, 0.5_353],
                ]
            ]     )

        # Running on the original tf implementation gives slightly different results here.
        # Not clear why this variations is present
        # TODO: Find reason for discrepancy
        # expected_original_implementation = [[
        #     [0.07630594074726105, -0.20146065950393677, 0.19107051193714142],
        #     [-0.3405614495277405, -0.36971670389175415, -0.4808273911476135],
        #     [-0.22587086260318756, -0.6656315922737122, -0.07844287157058716],
        #     [-0.04145475849509239, -0.3077218234539032, -0.42316967248916626],
        #     [-0.15887849032878876, -0.054529931396245956, 0.5356100797653198]
        # ]]

        self.assertTrue(torch.allclose(output["last_hidden_state"][:, :, :3]						,			lowerCAmelCase_						,			atol=1E-4     )     )



'''simple docstring'''
import itertools

def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE = 1_0_0_0_0_0_0							):
    """simple docstring"""






    snake_case_			:     Optional[int]        =    [1]

    for i in itertools.count(len(__SCREAMING_SNAKE_CASE							)							):
        snake_case_			:     str        =    0
        for j in itertools.count(1							):
            snake_case_			:     List[str]        =    -1 if j % 2 == 0 else +1
            snake_case_			:     str        =    (j * j * 3 - j) // 2
            if index > i:
                break
            item += partitions[i - index] * sign
            item %= number
            index += j
            if index > i:
                break
            item += partitions[i - index] * sign
            item %= number

        if item == 0:
            return i
        partitions.append(__SCREAMING_SNAKE_CASE							)

    return 0


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  print(f"""{solution() = }""")




