






'''simple docstring'''







from __future__ import annotations

import unittest

from transformers import AutoTokenizer, GPTJConfig, is_tf_available
from transformers.testing_utils import require_tf, slow, tooslow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin
from ...utils.test_modeling_tf_core import TFCoreModelTesterMixin


if is_tf_available():
			import tensorflow as tf

			from transformers.models.gptj.modeling_tf_gptj import (
			    TFGPTJForCausalLM,
			    TFGPTJForQuestionAnswering,
			    TFGPTJForSequenceClassification,
			    TFGPTJModel,
			    shape_list,
			)

class _lowercase      :




							def __init__(				self:							List[Any]     ,				UpperCamelCase__:							Optional[int]	):
														lowerCamelCase__   :      Dict			    =			parent
														lowerCamelCase__   :      Dict			    =			13
														lowerCamelCase__   :      List[str]			    =			7
														lowerCamelCase__   :      Tuple			    =			True
														lowerCamelCase__   :      Any			    =			True
														lowerCamelCase__   :      str			    =			True
														lowerCamelCase__   :      List[Any]			    =			True
														lowerCamelCase__   :      str			    =			True
														lowerCamelCase__   :      List[str]			    =			99
														lowerCamelCase__   :      List[str]			    =			32
														lowerCamelCase__   :      Union[str, Any]			    =			4
														lowerCamelCase__   :      Any			    =			2
														lowerCamelCase__   :      int			    =			4
														lowerCamelCase__   :      Any			    =			37
														lowerCamelCase__   :      Optional[int]			    =			"""gelu"""
														lowerCamelCase__   :      List[str]			    =			0.1
														lowerCamelCase__   :      List[str]			    =			0.1
														lowerCamelCase__   :      Any			    =			512
														lowerCamelCase__   :      Optional[int]			    =			16
														lowerCamelCase__   :      Tuple			    =			2
														lowerCamelCase__   :      Any			    =			0.02
														lowerCamelCase__   :      Tuple			    =			3
														lowerCamelCase__   :      Optional[int]			    =			4
														lowerCamelCase__   :      str			    =			None
														lowerCamelCase__   :      List[str]			    =			self.vocab_size - 1
														lowerCamelCase__   :      Union[str, Any]			    =			self.vocab_size - 1
														lowerCamelCase__   :      Optional[Any]			    =			self.vocab_size - 1




							def 						lowerCamelCase_							(				self:							Optional[Any]	):
														lowerCamelCase__   :      Any			    =			ids_tensor([self.batch_size, self.seq_length]     ,				self.vocab_size	)

														lowerCamelCase__   :      Optional[Any]			    =			None
														if self.use_input_mask:
																					lowerCamelCase__   :      Tuple			    =			random_attention_mask([self.batch_size, self.seq_length]	)

														lowerCamelCase__   :      int			    =			None
														if self.use_token_type_ids:
																					lowerCamelCase__   :      Union[str, Any]			    =			ids_tensor([self.batch_size, self.seq_length]     ,				self.type_vocab_size	)

														lowerCamelCase__   :      int			    =			None
														if self.use_mc_token_ids:
																					lowerCamelCase__   :      Tuple			    =			ids_tensor([self.batch_size, self.num_choices]     ,				self.seq_length	)

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

														lowerCamelCase__   :      int			    =			GPTJConfig(
														    vocab_size=self.vocab_size     ,				n_embd=self.hidden_size     ,				n_layer=self.num_hidden_layers     ,				n_head=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     ,				n_positions=self.max_position_embeddings     ,				type_vocab_size=self.type_vocab_size     ,				initializer_range=self.initializer_range     ,				bos_token_id=self.bos_token_id     ,				eos_token_id=self.eos_token_id     ,				pad_token_id=self.pad_token_id     ,				rotary_dim=self.rotary_dim     ,				return_dict=UpperCamelCase__     ,				)

														lowerCamelCase__   :      Tuple			    =			ids_tensor([self.num_hidden_layers, self.num_attention_heads]     ,				2	)

														return (
														    config,
														    input_ids,
														    input_mask,
														    head_mask,
														    token_type_ids,
														    mc_token_ids,
														    sequence_labels,
														    token_labels,
														    choice_labels,
														)




							def 						lowerCamelCase_							(				self:							Optional[Any]     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							Union[str, Any]     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							Any     ,				*UpperCamelCase__:							str	):
														lowerCamelCase__   :      str			    =			TFGPTJModel(config=UpperCamelCase__	)
														lowerCamelCase__   :      Any			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}
														lowerCamelCase__   :      str			    =			model(UpperCamelCase__	)

														lowerCamelCase__   :      Tuple			    =			[input_ids, None, input_mask]  # None is the input for 'past'
														lowerCamelCase__   :      Optional[Any]			    =			model(UpperCamelCase__	)

														lowerCamelCase__   :      Optional[Any]			    =			model(UpperCamelCase__	)

														self.parent.assertEqual(result.last_hidden_state.shape     ,				(self.batch_size, self.seq_length, self.hidden_size)	)




							def 						lowerCamelCase_							(				self:							List[Any]     ,				UpperCamelCase__:							Union[str, Any]     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							Dict     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							Tuple     ,				*UpperCamelCase__:							str	):
														lowerCamelCase__   :      Any			    =			TFGPTJModel(config=UpperCamelCase__	)

														# first forward pass
														lowerCamelCase__   :      List[Any]			    =			model(UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				use_cache=UpperCamelCase__	)
														lowerCamelCase__   :      Union[str, Any]			    =			model(UpperCamelCase__     ,				token_type_ids=UpperCamelCase__	)
														lowerCamelCase__   :      str			    =			model(UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				use_cache=UpperCamelCase__	)

														self.parent.assertTrue(len(UpperCamelCase__	) == len(UpperCamelCase__	)	)
														self.parent.assertTrue(len(UpperCamelCase__	) == len(UpperCamelCase__	) + 1	)

														lowerCamelCase__    ,						lowerCamelCase__   :      Dict			    =			outputs.to_tuple()

														# create hypothetical next token and extent to next_input_ids
														lowerCamelCase__   :      List[str]			    =			ids_tensor((self.batch_size, 1)     ,				config.vocab_size	)
														lowerCamelCase__   :      List[str]			    =			ids_tensor([self.batch_size, 1]     ,				self.type_vocab_size	)

														# append to next input_ids and token_type_ids
														lowerCamelCase__   :      int			    =			tf.concat([input_ids, next_tokens]     ,				axis=-1	)
														lowerCamelCase__   :      int			    =			tf.concat([token_type_ids, next_token_types]     ,				axis=-1	)

														lowerCamelCase__   :      Dict			    =			model(UpperCamelCase__     ,				token_type_ids=UpperCamelCase__	)["""last_hidden_state"""]
														lowerCamelCase__   :      Any			    =			model(UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				past_key_values=UpperCamelCase__	)[
														    """last_hidden_state"""
														]

														# select random slice
														lowerCamelCase__   :      Optional[Any]			    =			int(ids_tensor((1,)     ,				shape_list(UpperCamelCase__	)[-1]	)	)
														lowerCamelCase__   :      Optional[Any]			    =			output_from_no_past[:, -1, random_slice_idx]
														lowerCamelCase__   :      Tuple			    =			output_from_past[:, 0, random_slice_idx]

														# test that outputs are equal for slice
														tf.debugging.assert_near(UpperCamelCase__     ,				UpperCamelCase__     ,				rtol=1e-6	)




							def 						lowerCamelCase_							(				self:							Union[str, Any]     ,				UpperCamelCase__:							List[Any]     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							int     ,				*UpperCamelCase__:							int	):
														lowerCamelCase__   :      Tuple			    =			TFGPTJModel(config=UpperCamelCase__	)

														# create attention mask
														lowerCamelCase__   :      Any			    =			self.seq_length // 2
														lowerCamelCase__   :      Union[str, Any]			    =			tf.ones((self.batch_size, half_seq_length)     ,				dtype=tf.intaa	)
														lowerCamelCase__   :      List[Any]			    =			tf.zeros((self.batch_size, self.seq_length - half_seq_length)     ,				dtype=tf.intaa	)
														lowerCamelCase__   :      Tuple			    =			tf.concat([attn_mask_begin, attn_mask_end]     ,				axis=1	)

														# first forward pass
														lowerCamelCase__    ,						lowerCamelCase__   :      Optional[int]			    =			model(UpperCamelCase__     ,				attention_mask=UpperCamelCase__	).to_tuple()

														# create hypothetical next token and extent to next_input_ids
														lowerCamelCase__   :      List[Any]			    =			ids_tensor((self.batch_size, 1)     ,				config.vocab_size	)

														# change a random masked slice from input_ids
														lowerCamelCase__   :      Any			    =			ids_tensor((1,)     ,				UpperCamelCase__	).numpy() + 1
														lowerCamelCase__   :      Any			    =			ids_tensor((self.batch_size, self.seq_length)     ,				config.vocab_size	)
														lowerCamelCase__   :      List[str]			    =			tf.range(self.seq_length	) == (self.seq_length - random_seq_idx_to_change)
														lowerCamelCase__   :      List[str]			    =			tf.transpose(
														    tf.broadcast_to(tf.expand_dims(UpperCamelCase__     ,				-1	)     ,				(self.seq_length, self.batch_size)	)	)
														lowerCamelCase__   :      Any			    =			tf.where(UpperCamelCase__     ,				UpperCamelCase__     ,				UpperCamelCase__	)

														# append to next input_ids and attn_mask
														lowerCamelCase__   :      Optional[Any]			    =			tf.concat([input_ids, next_tokens]     ,				axis=-1	)
														lowerCamelCase__   :      Optional[Any]			    =			tf.concat([attn_mask, tf.ones((shape_list(UpperCamelCase__	)[0], 1)     ,				dtype=tf.intaa	)]     ,				axis=1	)

														# get two different outputs
														lowerCamelCase__   :      Optional[Any]			    =			model(UpperCamelCase__     ,				attention_mask=UpperCamelCase__	)["""last_hidden_state"""]
														lowerCamelCase__   :      Tuple			    =			model(UpperCamelCase__     ,				past_key_values=UpperCamelCase__     ,				attention_mask=UpperCamelCase__	)[
														    """last_hidden_state"""
														]

														# select random slice
														lowerCamelCase__   :      Any			    =			int(ids_tensor((1,)     ,				shape_list(UpperCamelCase__	)[-1]	)	)
														lowerCamelCase__   :      Tuple			    =			output_from_no_past[:, -1, random_slice_idx]
														lowerCamelCase__   :      List[str]			    =			output_from_past[:, 0, random_slice_idx]

														# test that outputs are equal for slice
														tf.debugging.assert_near(UpperCamelCase__     ,				UpperCamelCase__     ,				rtol=1e-12	)




							def 						lowerCamelCase_							(				self:							int     ,				UpperCamelCase__:							Any     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							List[Any]     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							List[str]     ,				*UpperCamelCase__:							Union[str, Any]	):
														lowerCamelCase__   :      List[Any]			    =			TFGPTJModel(config=UpperCamelCase__	)

														lowerCamelCase__   :      int			    =			input_ids[:1, :]
														lowerCamelCase__   :      Tuple			    =			input_mask[:1, :]
														lowerCamelCase__   :      Union[str, Any]			    =			token_type_ids[:1, :]
														lowerCamelCase__   :      str			    =			1

														# first forward pass
														lowerCamelCase__   :      Any			    =			model(UpperCamelCase__     ,				attention_mask=UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				use_cache=UpperCamelCase__	)

														lowerCamelCase__    ,						lowerCamelCase__   :      str			    =			outputs.to_tuple()

														# create hypothetical next token and extent to next_input_ids
														lowerCamelCase__   :      List[str]			    =			ids_tensor((self.batch_size, 3)     ,				config.vocab_size	)
														lowerCamelCase__   :      Any			    =			ids_tensor((self.batch_size, 3)     ,				2	)
														lowerCamelCase__   :      Tuple			    =			ids_tensor((self.batch_size, 3)     ,				self.type_vocab_size	)

														# append to next input_ids and token_type_ids
														lowerCamelCase__   :      List[Any]			    =			tf.concat([input_ids, next_tokens]     ,				axis=-1	)
														lowerCamelCase__   :      Union[str, Any]			    =			tf.concat([input_mask, next_attn_mask]     ,				axis=-1	)
														lowerCamelCase__   :      Tuple			    =			tf.concat([token_type_ids, next_token_types]     ,				axis=-1	)

														lowerCamelCase__   :      int			    =			model(
														    UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				attention_mask=UpperCamelCase__	)["""last_hidden_state"""]
														lowerCamelCase__   :      Optional[Any]			    =			model(
														    UpperCamelCase__     ,				token_type_ids=UpperCamelCase__     ,				attention_mask=UpperCamelCase__     ,				past_key_values=UpperCamelCase__     ,				)["""last_hidden_state"""]
														self.parent.assertTrue(output_from_past.shape[1] == next_tokens.shape[1]	)

														# select random slice
														lowerCamelCase__   :      int			    =			int(ids_tensor((1,)     ,				shape_list(UpperCamelCase__	)[-1]	)	)
														lowerCamelCase__   :      Optional[Any]			    =			output_from_no_past[:, -3:, random_slice_idx]
														lowerCamelCase__   :      Union[str, Any]			    =			output_from_past[:, :, random_slice_idx]

														# test that outputs are equal for slice
														tf.debugging.assert_near(UpperCamelCase__     ,				UpperCamelCase__     ,				rtol=1e-3	)




							def 						lowerCamelCase_							(				self:							Any     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							Any     ,				*UpperCamelCase__:							Any	):
														lowerCamelCase__   :      Union[str, Any]			    =			TFGPTJForCausalLM(config=UpperCamelCase__	)
														lowerCamelCase__   :      Optional[int]			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}
														lowerCamelCase__   :      Dict			    =			model(UpperCamelCase__	)
														self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.seq_length, self.vocab_size)	)




							def 						lowerCamelCase_							(				self:							List[str]	):
														lowerCamelCase__   :      Union[str, Any]			    =			self.prepare_config_and_inputs()

														(
														    (
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						    
														)   :      List[Any]			    =			config_and_inputs

														lowerCamelCase__   :      List[Any]			    =			{
														    """input_ids""": input_ids,
														    """token_type_ids""": token_type_ids,
														    """attention_mask""": input_mask,
														}
														return config, inputs_dict



@require_tf
class _lowercase      (							lowerCamelCase_							, lowerCamelCase_							, lowerCamelCase_							, unittest.TestCase						):
							a							 =			(
							    (TFGPTJForCausalLM, TFGPTJForSequenceClassification, TFGPTJForQuestionAnswering, TFGPTJModel)
							    if is_tf_available()
							    else ()
							)

							a							 =			(TFGPTJForCausalLM,) if is_tf_available() else ()
							a							 =			(
							    {
							        """feature-extraction""": TFGPTJModel,
							        """question-answering""": TFGPTJForQuestionAnswering,
							        """text-classification""": TFGPTJForSequenceClassification,
							        """text-generation""": TFGPTJForCausalLM,
							        """zero-shot""": TFGPTJForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							a							 =			False
							a							 =			False
							a							 =			False
							a							 =			False




							def 						lowerCamelCase_							(				self:							Dict     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							Dict     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							str	):
														if (
														    pipeline_test_casse_name == "QAPipelineTests"
														    and tokenizer_name is not None
														    and not tokenizer_name.endswith("""Fast"""	)
														):
																					# `QAPipelineTests` fails for a few models when the slower tokenizer are used.
																					# (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
																					# TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
																					return True

														return False




							def 						lowerCamelCase_							(				self:							Union[str, Any]	):
														lowerCamelCase__   :      Tuple			    =			TFGPTJModelTester(self	)
														lowerCamelCase__   :      Optional[Any]			    =			ConfigTester(self     ,				config_class=UpperCamelCase__     ,				n_embd=37	)




							def 						lowerCamelCase_							(				self:							List[str]	):
														self.config_tester.run_common_tests()




							def 						lowerCamelCase_							(				self:							str	):
														lowerCamelCase__   :      List[Any]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_gptj_model(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Dict	):
														lowerCamelCase__   :      Optional[Any]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_gptj_model_past(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Tuple	):
														lowerCamelCase__   :      int			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_gptj_model_attention_mask_past(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							List[Any]	):
														lowerCamelCase__   :      List[str]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_gptj_model_past_large_inputs(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Dict	):
														lowerCamelCase__   :      List[Any]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_gptj_lm_head_model(*UpperCamelCase__	)




							@slow
							@unittest.skipIf(
							    not is_tf_available() or len(tf.config.list_physical_devices("""GPU"""	)	) > 0     ,				"""skip testing on GPU for now to avoid GPU OOM."""     ,				)
							def 						lowerCamelCase_							(				self:							Optional[Any]	):
														lowerCamelCase__   :      Union[str, Any]			    =			TFGPTJModel.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				from_pt=UpperCamelCase__	)
														self.assertIsNotNone(UpperCamelCase__	)




							@unittest.skip(reason="""Currently, model embeddings are going to undergo a major refactor."""	)
							def 						lowerCamelCase_							(				self:							int	):
														super().test_resize_token_embeddings()



@require_tf
@tooslow
# Marked as @tooslow due to GPU OOM -- but still useful to run locally. Requires ~39GB of RAM.
class _lowercase      (							unittest.TestCase						):




							def 						lowerCamelCase_							(				self:							Tuple	):
														lowerCamelCase__   :      Any			    =			TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				from_pt=UpperCamelCase__	)
														lowerCamelCase__   :      Union[str, Any]			    =			tf.convert_to_tensor([[464, 3_290]]     ,				dtype=tf.intaa	)  # The dog
														# fmt: off
														# The dog is a man's best friend. It is a loyal companion, and it is a friend
														lowerCamelCase__   :      Optional[Any]			    =			[464, 3_290, 318, 257, 582, 338, 1_266, 1_545, 13, 632, 318, 257, 9_112, 15_185, 11, 290, 340, 318, 257, 1_545]
														# fmt: on
														lowerCamelCase__   :      Tuple			    =			model.generate(UpperCamelCase__     ,				do_sample=UpperCamelCase__	)
														self.assertListEqual(output_ids[0].numpy().tolist()     ,				UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Optional[Any]	):
														lowerCamelCase__   :      Optional[Any]			    =			AutoTokenizer.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				revision="""float16"""	)
														lowerCamelCase__   :      int			    =			TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				revision="""float16"""     ,				from_pt=UpperCamelCase__	)

														lowerCamelCase__   :      List[Any]			    =			tokenizer("""Today is a nice day and"""     ,				return_tensors="""tf"""	)
														# forces the generation to happen on CPU, to avoid GPU-related quirks
														with tf.device(""":/CPU:0"""	):
																					lowerCamelCase__   :      Tuple			    =			model.generate(**UpperCamelCase__     ,				do_sample=UpperCamelCase__     ,				seed=[42, 0]	)
														lowerCamelCase__   :      List[str]			    =			tokenizer.decode(output_ids[0]     ,				skip_special_tokens=UpperCamelCase__	)

														lowerCamelCase__   :      List[str]			    =			"""Today is a nice day and I’m going to go for a walk. I’"""
														self.assertEqual(UpperCamelCase__     ,				UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Optional[int]	):
														lowerCamelCase__   :      List[str]			    =			TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				revision="""float16"""     ,				from_pt=UpperCamelCase__	)
														lowerCamelCase__   :      int			    =			AutoTokenizer.from_pretrained("""EleutherAI/gpt-j-6B"""     ,				revision="""float16"""	)

														lowerCamelCase__   :      List[Any]			    =			"""left"""

														# Define PAD Token = EOS Token = 50256
														lowerCamelCase__   :      Dict			    =			tokenizer.eos_token
														lowerCamelCase__   :      Union[str, Any]			    =			model.config.eos_token_id

														# use different length sentences to test batching
														lowerCamelCase__   :      Optional[int]			    =			[
														    """Hello, my dog is a little""",
														    """Today, I""",
														]
														lowerCamelCase__   :      str			    =			[
														    """Hello, my dog is a little over a year old and has been diagnosed with hip dysplasia""",
														    """Today, I’m going to be talking about a topic that’""",
														]
														return model, tokenizer, sentences, expected_output_sentences




							def 						lowerCamelCase_							(				self:							List[Any]	):
														# Confirms that we get the expected results with left-padded beam search
														lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__   :      Any			    =			self._get_beam_search_test_objects()

														lowerCamelCase__   :      List[str]			    =			tokenizer(UpperCamelCase__     ,				return_tensors="""tf"""     ,				padding=UpperCamelCase__	)
														lowerCamelCase__   :      Union[str, Any]			    =			model.generate(**UpperCamelCase__     ,				do_sample=UpperCamelCase__     ,				num_beams=2	)
														lowerCamelCase__   :      Optional[int]			    =			tokenizer.batch_decode(UpperCamelCase__     ,				skip_special_tokens=UpperCamelCase__	)
														self.assertListEqual(UpperCamelCase__     ,				UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							int	):
														# Confirms that left-padding is working properly
														lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__   :      List[str]			    =			self._get_beam_search_test_objects()

														lowerCamelCase__   :      Union[str, Any]			    =			tokenizer(UpperCamelCase__     ,				return_tensors="""tf"""     ,				padding=UpperCamelCase__	)
														lowerCamelCase__   :      List[str]			    =			tokenizer(sentences[0]     ,				return_tensors="""tf"""	)
														lowerCamelCase__   :      Any			    =			model.generate(**UpperCamelCase__     ,				do_sample=UpperCamelCase__     ,				num_beams=2	)
														lowerCamelCase__   :      List[str]			    =			(
														    shape_list(inputs_non_padded["""input_ids"""]	)[-1]
														    - tf.reduce_sum(tf.cast(inputs["""attention_mask"""][-1]     ,				tf.intaa	)	).numpy()
														)
														lowerCamelCase__   :      str			    =			tokenizer(sentences[1]     ,				return_tensors="""tf"""	)
														lowerCamelCase__   :      List[str]			    =			model.generate(
														    **UpperCamelCase__     ,				do_sample=UpperCamelCase__     ,				num_beams=2     ,				max_length=model.config.max_length - num_paddings	)
														lowerCamelCase__   :      str			    =			tokenizer.decode(output_non_padded[0]     ,				skip_special_tokens=UpperCamelCase__	)
														lowerCamelCase__   :      Tuple			    =			tokenizer.decode(output_padded[0]     ,				skip_special_tokens=UpperCamelCase__	)
														self.assertListEqual(UpperCamelCase__     ,				[non_padded_sentence, padded_sentence]	)




							def 						lowerCamelCase_							(				self:							Any	):
														# Confirms that XLA is working properly
														lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__   :      Union[str, Any]			    =			self._get_beam_search_test_objects()

														lowerCamelCase__   :      Any			    =			tokenizer(UpperCamelCase__     ,				return_tensors="""tf"""     ,				padding=UpperCamelCase__	)
														lowerCamelCase__   :      List[Any]			    =			tf.function(model.generate     ,				jit_compile=UpperCamelCase__	)
														lowerCamelCase__   :      Optional[Any]			    =			xla_generate(**UpperCamelCase__     ,				do_sample=UpperCamelCase__     ,				num_beams=2	)
														lowerCamelCase__   :      Optional[Any]			    =			tokenizer.batch_decode(UpperCamelCase__     ,				skip_special_tokens=UpperCamelCase__	)
														self.assertListEqual(UpperCamelCase__     ,				UpperCamelCase__	)




def      snake_case__							(  lowerCAmelCase_ = 100     ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=[[0 for _ in range(lowerCAmelCase_     )] for _ in range(m + 1     )]
     for i in range(m + 1     ):
          SCREAMING_SNAKE_CASE 		=1

     for n in range(m + 1     ):
          for k in range(1,       lowerCAmelCase_     ):
               memo[n][k] += memo[n][k - 1]
               if n > k:
                    memo[n][k] += memo[n - k - 1][k]

     return memo[m][m - 1] - 1


if __name__ == "__main__":
 print(solution(int(input("Enter a number: ").strip())))

