


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:


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




											'''simple docstring'''

											__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				=		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 				SCREAMING_SNAKE_CASE_	(    self						:		Union[str, Any]    )      ->						Any:




											'''simple docstring'''

											__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

											__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				=		self.get_config()

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


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[str]    )      ->						Optional[Any]:




											'''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=SCREAMING_SNAKE_CASE  ,     initializer_range=self.initializer_range  ,     pad_token_id=1  ,     new_decoder_architecture=SCREAMING_SNAKE_CASE  ,     )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		int  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		Dict    )      ->						List[Any]:




											'''simple docstring'''

											__snake_case				=		FalconModel(config=SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE    )
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, self.seq_length, self.hidden_size)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		str  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     )      ->						Tuple:




											'''simple docstring'''

											__snake_case				=		True
											__snake_case				=		FalconModel(SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(
											    SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     encoder_hidden_states=SCREAMING_SNAKE_CASE  ,     encoder_attention_mask=SCREAMING_SNAKE_CASE  ,     )
											__snake_case				=		model(
											    SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     encoder_hidden_states=SCREAMING_SNAKE_CASE  ,     )
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, self.seq_length, self.hidden_size)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     )      ->						Union[str, Any]:




											'''simple docstring'''

											__snake_case				=		FalconForCausalLM(config=SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     labels=SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.vocab_size)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Any  ,     SCREAMING_SNAKE_CASE						:		Any  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Any  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     )      ->						Tuple:




											'''simple docstring'''

											__snake_case				=		True
											__snake_case				=		True
											__snake_case				=		FalconForCausalLM(config=SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()

											# first forward pass
											__snake_case				=		model(
											    SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     encoder_hidden_states=SCREAMING_SNAKE_CASE  ,     encoder_attention_mask=SCREAMING_SNAKE_CASE  ,     use_cache=SCREAMING_SNAKE_CASE  ,     )
											__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(
											    SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     encoder_hidden_states=SCREAMING_SNAKE_CASE  ,     encoder_attention_mask=SCREAMING_SNAKE_CASE  ,     output_hidden_states=SCREAMING_SNAKE_CASE  ,     )["hidden_states"][0]
											__snake_case				=		model(
											    SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     encoder_hidden_states=SCREAMING_SNAKE_CASE  ,     encoder_attention_mask=SCREAMING_SNAKE_CASE  ,     past_key_values=SCREAMING_SNAKE_CASE  ,     output_hidden_states=SCREAMING_SNAKE_CASE  ,     )["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(SCREAMING_SNAKE_CASE  ,     SCREAMING_SNAKE_CASE  ,     atol=1e-3    )    )






					def 				SCREAMING_SNAKE_CASE_	(    self						:		int    )      ->						str:




											'''simple docstring'''

											__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, "attention_mask": input_mask}
											return config, inputs_dict






@require_torch
class      UpperCamelCase(	_a  ,				_a  ,				_a  ,				unittest.TestCase ):
					snake_case_		:					Optional[Any]    					=						(
					    (
					        FalconModel,
					        FalconForCausalLM,
					        FalconForSequenceClassification,
					        FalconForTokenClassification,
					        FalconForQuestionAnswering,
					    )
					    if is_torch_available()
					    else ()
					)
					snake_case_		:					List[Any]    					=						(FalconForCausalLM,) if is_torch_available() else ()
					snake_case_		:					Optional[int]    					=						(
					    {
					        """feature-extraction""": FalconModel,
					        """text-classification""": FalconForSequenceClassification,
					        """text-generation""": FalconForCausalLM,
					        """question-answering""": FalconForQuestionAnswering,
					        """token-classification""": FalconForTokenClassification,
					        """zero-shot""": FalconForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)
					snake_case_		:					Union[str, Any]    					=						False
					snake_case_		:					Dict    					=						False


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




											'''simple docstring'''

											__snake_case				=		FalconModelTester(self    )
											__snake_case				=		ConfigTester(self  ,     config_class=SCREAMING_SNAKE_CASE  ,     hidden_size=3_7    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[int]    )      ->						Tuple:




											'''simple docstring'''

											self.config_tester.run_common_tests()


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Tuple    )      ->						List[Any]:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE    )


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




											'''simple docstring'''

											__snake_case		,       *__snake_case				=		self.model_tester.prepare_config_and_inputs()
											for alibi in [True, False]:
																	__snake_case				=		alibi
																	self.model_tester.create_and_check_model(SCREAMING_SNAKE_CASE  ,     *SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[Any]    )      ->						List[Any]:




											'''simple docstring'''

											__snake_case		,       __snake_case				=		self.model_tester.prepare_config_and_inputs_for_common()
											__snake_case				=		3
											__snake_case				=		input_dict["input_ids"]
											__snake_case				=		input_ids.ne(1    ).to(SCREAMING_SNAKE_CASE    )
											__snake_case				=		ids_tensor([self.model_tester.batch_size]  ,     self.model_tester.type_sequence_label_size    )
											__snake_case				=		FalconForSequenceClassification(SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     labels=SCREAMING_SNAKE_CASE    )
											self.assertEqual(result.logits.shape  ,     (self.model_tester.batch_size, self.model_tester.num_labels)    )


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




											'''simple docstring'''

											__snake_case		,       __snake_case				=		self.model_tester.prepare_config_and_inputs_for_common()
											__snake_case				=		3
											__snake_case				=		"single_label_classification"
											__snake_case				=		input_dict["input_ids"]
											__snake_case				=		input_ids.ne(1    ).to(SCREAMING_SNAKE_CASE    )
											__snake_case				=		ids_tensor([self.model_tester.batch_size]  ,     self.model_tester.type_sequence_label_size    )
											__snake_case				=		FalconForSequenceClassification(SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     labels=SCREAMING_SNAKE_CASE    )
											self.assertEqual(result.logits.shape  ,     (self.model_tester.batch_size, self.model_tester.num_labels)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[int]    )      ->						Any:




											'''simple docstring'''

											__snake_case		,       __snake_case				=		self.model_tester.prepare_config_and_inputs_for_common()
											__snake_case				=		input_dict["input_ids"]
											__snake_case				=		FalconForCausalLM(SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     use_cache=SCREAMING_SNAKE_CASE    )
											__snake_case				=		input_ids.shape[0]
											__snake_case				=		model._convert_to_rw_cache(result.past_key_values    )
											__snake_case				=		model._convert_cache_to_standard_format(SCREAMING_SNAKE_CASE  ,     SCREAMING_SNAKE_CASE    )
											for layer in range(len(SCREAMING_SNAKE_CASE    )    ):
																	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 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[Any]    )      ->						Optional[Any]:




											'''simple docstring'''

											__snake_case		,       __snake_case				=		self.model_tester.prepare_config_and_inputs_for_common()
											__snake_case				=		3
											__snake_case				=		"multi_label_classification"
											__snake_case				=		input_dict["input_ids"]
											__snake_case				=		input_ids.ne(1    ).to(SCREAMING_SNAKE_CASE    )
											__snake_case				=		ids_tensor(
											    [self.model_tester.batch_size, config.num_labels]  ,     self.model_tester.type_sequence_label_size    ).to(torch.float    )
											__snake_case				=		FalconForSequenceClassification(SCREAMING_SNAKE_CASE    )
											model.to(SCREAMING_SNAKE_CASE    )
											model.eval()
											__snake_case				=		model(SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE  ,     labels=SCREAMING_SNAKE_CASE    )
											self.assertEqual(result.logits.shape  ,     (self.model_tester.batch_size, self.model_tester.num_labels)    )






					def 				SCREAMING_SNAKE_CASE_	(    self						:		Tuple    )      ->						Any:




											'''simple docstring'''

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

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

																	__snake_case				=		model_class(SCREAMING_SNAKE_CASE    ).to(SCREAMING_SNAKE_CASE    )
																	if "use_cache" not in inputs:
																							__snake_case				=		True
																	__snake_case				=		model(**SCREAMING_SNAKE_CASE    )

																	# 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

																	__snake_case				=		(
																	    getattr(SCREAMING_SNAKE_CASE  ,     "decoder_layers"  ,     SCREAMING_SNAKE_CASE    )
																	    or getattr(SCREAMING_SNAKE_CASE  ,     "num_decoder_layers"  ,     SCREAMING_SNAKE_CASE    )
																	    or config.num_hidden_layers
																	)
																	__snake_case				=		getattr(SCREAMING_SNAKE_CASE  ,     "num_kv_heads"  ,     config.num_attention_heads    )
																	__snake_case				=		getattr(SCREAMING_SNAKE_CASE  ,     "d_model"  ,     config.hidden_size    )
																	__snake_case				=		embed_dim // num_attention_heads

																	__snake_case				=		outputs["past_key_values"]
																	self.assertEqual(len(SCREAMING_SNAKE_CASE    )  ,     SCREAMING_SNAKE_CASE    )

																	__snake_case		,       __snake_case				=		inputs["input_ids"].shape
																	for i in range(SCREAMING_SNAKE_CASE    ):
																							if config.new_decoder_architecture:
																													__snake_case				=		config.num_attention_heads
																							elif config.multi_query:
																													__snake_case				=		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 ):


					@slow
					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[str]    )      ->						List[str]:




											'''simple docstring'''

											__snake_case				=		AutoTokenizer.from_pretrained("Rocketknight1/falcon-rw-1b"    )
											__snake_case				=		FalconForCausalLM.from_pretrained("Rocketknight1/falcon-rw-1b"    )
											model.eval()
											model.to(SCREAMING_SNAKE_CASE    )
											__snake_case				=		tokenizer("My favorite food is"  ,     return_tensors="pt"    ).to(SCREAMING_SNAKE_CASE    )

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

											__snake_case				=		model.generate(**SCREAMING_SNAKE_CASE  ,     do_sample=SCREAMING_SNAKE_CASE  ,     max_new_tokens=1_9    )
											__snake_case				=		tokenizer.batch_decode(SCREAMING_SNAKE_CASE    )[0]

											self.assertEqual(SCREAMING_SNAKE_CASE  ,     SCREAMING_SNAKE_CASE    )


					@slow
					def 				SCREAMING_SNAKE_CASE_	(    self						:		Dict    )      ->						Optional[Any]:




											'''simple docstring'''

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

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






					@slow
					def 				SCREAMING_SNAKE_CASE_	(    self						:		Union[str, Any]    )      ->						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",
																	]:
																							__snake_case				=		AutoTokenizer.from_pretrained(SCREAMING_SNAKE_CASE    )
																							__snake_case				=		FalconForCausalLM.from_pretrained(SCREAMING_SNAKE_CASE    )
																							model.eval()
																							model.to(device=SCREAMING_SNAKE_CASE    )
																							__snake_case				=		tokenizer("My favorite food is"  ,     return_tensors="pt"    ).to(SCREAMING_SNAKE_CASE    )

																							# Test results are the same with and without cache
																							__snake_case				=		model.generate(**SCREAMING_SNAKE_CASE  ,     do_sample=SCREAMING_SNAKE_CASE  ,     max_new_tokens=2_0  ,     use_cache=SCREAMING_SNAKE_CASE    )
																							__snake_case				=		model.generate(**SCREAMING_SNAKE_CASE  ,     do_sample=SCREAMING_SNAKE_CASE  ,     max_new_tokens=2_0  ,     use_cache=SCREAMING_SNAKE_CASE    )
																							self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0    )









def 						_lowerCAmelCase							(     _lowerCAmelCase = 1000			)    ->						int:


						'''simple docstring'''






						__snake_case				=		2**power
						__snake_case				=		str(_lowerCAmelCase			)
						__snake_case				=		list(_lowerCAmelCase			)
						__snake_case				=		0

						for i in list_num:
												sum_of_num += int(_lowerCAmelCase			)

						return sum_of_num


if __name__ == "__main__":
	A				:       Optional[Any]      =  int(input('Enter the power of 2: ').strip())
	print('2 ^ ', power, ' = ', 2**power)
	A				:       List[Any]      =  solution(power)
	print('Sum of the digits is: ', result)





