





import unittest

from transformers import FunnelConfig, FunnelTokenizer, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

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


if is_torch_available():
				import torch

				from transformers import (
				    MODEL_FOR_PRETRAINING_MAPPING,
				    FunnelBaseModel,
				    FunnelForMaskedLM,
				    FunnelForMultipleChoice,
				    FunnelForPreTraining,
				    FunnelForQuestionAnswering,
				    FunnelForSequenceClassification,
				    FunnelForTokenClassification,
				    FunnelModel,
				)



class  _a  :






							"""simple docstring"""

							def __init__(   self					:  int				,						a					:  str				,						a					:  List[str]=13				,						a					:  Tuple=7				,						a					:  str=True				,						a					:  Tuple=True				,						a					:  List[Any]=True				,						a					:  Optional[Any]=True				,						a					:  Dict=99				,						a					:  Dict=[1, 1, 2]				,						a					:  Optional[Any]=1				,						a					:  Tuple=32				,						a					:  Tuple=4				,						a					:  List[Any]=8				,						a					:  int=37				,						a					:  Union[str, Any]="gelu_new"				,						a					:  str=0.1				,						a					:  List[str]=0.1				,						a					:  List[str]=0.0				,						a					:  List[str]=5_12				,						a					:  int=3				,						a					:  List[str]=0.02				,						a					:  Tuple=3				,						a					:  Any=4				,						a					:  Any=None				,						a					:  Union[str, Any]=False				,						)						->Dict:
													SCREAMING_SNAKE_CASE__  :					List[str] =       parent
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       batch_size
													SCREAMING_SNAKE_CASE__  :					Any =       seq_length
													SCREAMING_SNAKE_CASE__  :					str =       is_training
													SCREAMING_SNAKE_CASE__  :					Tuple =       use_input_mask
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       use_token_type_ids
													SCREAMING_SNAKE_CASE__  :					Any =       use_labels
													SCREAMING_SNAKE_CASE__  :					Dict =       vocab_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       block_sizes
													SCREAMING_SNAKE_CASE__  :					List[Any] =       num_decoder_layers
													SCREAMING_SNAKE_CASE__  :					List[str] =       d_model
													SCREAMING_SNAKE_CASE__  :					str =       n_head
													SCREAMING_SNAKE_CASE__  :					Dict =       d_head
													SCREAMING_SNAKE_CASE__  :					List[str] =       d_inner
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					str =       hidden_dropout
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       attention_dropout
													SCREAMING_SNAKE_CASE__  :					Dict =       activation_dropout
													SCREAMING_SNAKE_CASE__  :					List[str] =       max_position_embeddings
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       type_vocab_size
													SCREAMING_SNAKE_CASE__  :					Dict =       2
													SCREAMING_SNAKE_CASE__  :					Tuple =       num_labels
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       num_choices
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       scope
													SCREAMING_SNAKE_CASE__  :					Tuple =       initializer_std

													# Used in the tests to check the size of the first attention layer
													SCREAMING_SNAKE_CASE__  :					List[Any] =       n_head
													# Used in the tests to check the size of the first hidden state
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       self.d_model
													# Used in the tests to check the number of output hidden states/attentions
													SCREAMING_SNAKE_CASE__  :					List[Any] =       sum(self.block_sizes     ) + (0 if base else self.num_decoder_layers)
													# FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
													# the last hidden state of the first block (which is the first hidden state of the decoder).
													if not base:
																			SCREAMING_SNAKE_CASE__  :					Any =       self.num_hidden_layers + 2

							def   A_	(   self					:  Union[str, Any]     )						->Optional[int]:
													SCREAMING_SNAKE_CASE__  :					Any =       ids_tensor([self.batch_size, self.seq_length]				,						self.vocab_size     )

													SCREAMING_SNAKE_CASE__  :					Tuple =       None
													if self.use_input_mask:
																			SCREAMING_SNAKE_CASE__  :					List[str] =       ids_tensor([self.batch_size, self.seq_length]				,						vocab_size=2     )

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

													SCREAMING_SNAKE_CASE__  :					Any =       None
													SCREAMING_SNAKE_CASE__  :					int =       None
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       None
													if self.use_labels:
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       ids_tensor([self.batch_size]				,						self.type_sequence_label_size     )
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       ids_tensor([self.batch_size, self.seq_length]				,						self.num_labels     )
																			SCREAMING_SNAKE_CASE__  :					Optional[Any] =       ids_tensor([self.batch_size]				,						self.num_choices     )
																			SCREAMING_SNAKE_CASE__  :					List[str] =       ids_tensor([self.batch_size, self.seq_length]				,						1     )

													SCREAMING_SNAKE_CASE__  :					Any =       self.get_config()

													return (
													    config,
													    input_ids,
													    token_type_ids,
													    input_mask,
													    sequence_labels,
													    token_labels,
													    choice_labels,
													    fake_token_labels,
													)

							def   A_	(   self					:  Optional[Any]     )						->Any:
													return FunnelConfig(
													    vocab_size=self.vocab_size				,						block_sizes=self.block_sizes				,						num_decoder_layers=self.num_decoder_layers				,						d_model=self.d_model				,						n_head=self.n_head				,						d_head=self.d_head				,						d_inner=self.d_inner				,						hidden_act=self.hidden_act				,						hidden_dropout=self.hidden_dropout				,						attention_dropout=self.attention_dropout				,						activation_dropout=self.activation_dropout				,						max_position_embeddings=self.max_position_embeddings				,						type_vocab_size=self.type_vocab_size				,						initializer_std=self.initializer_std				,						)

							def   A_	(   self					:  Any				,						a					:  List[Any]				,						a					:  Optional[Any]				,						a					:  Dict				,						a					:  Optional[Any]				,						a					:  Any				,						a					:  Union[str, Any]				,						a					:  List[Any]				,						a					:  Union[str, Any]				,						)						->List[Any]:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FunnelModel(config=a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					Tuple =       model(a				,						attention_mask=a				,						token_type_ids=a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       model(a				,						token_type_ids=a     )
													SCREAMING_SNAKE_CASE__  :					int =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, self.seq_length, self.d_model)     )

													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       False
													SCREAMING_SNAKE_CASE__  :					int =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, self.seq_length, self.d_model)     )

													SCREAMING_SNAKE_CASE__  :					Dict =       False
													SCREAMING_SNAKE_CASE__  :					int =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, self.seq_length, self.d_model)     )

							def   A_	(   self					:  Union[str, Any]				,						a					:  List[str]				,						a					:  Optional[Any]				,						a					:  Tuple				,						a					:  Tuple				,						a					:  Optional[Any]				,						a					:  List[Any]				,						a					:  List[Any]				,						a					:  List[str]				,						)						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					List[str] =       FunnelBaseModel(config=a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					int =       model(a				,						attention_mask=a				,						token_type_ids=a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       model(a				,						token_type_ids=a     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, 2, self.d_model)     )

													SCREAMING_SNAKE_CASE__  :					Any =       False
													SCREAMING_SNAKE_CASE__  :					List[Any] =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, 3, self.d_model)     )

													SCREAMING_SNAKE_CASE__  :					Dict =       False
													SCREAMING_SNAKE_CASE__  :					str =       model(a     )
													self.parent.assertEqual(result.last_hidden_state.shape				,						(self.batch_size, 2, self.d_model)     )

							def   A_	(   self					:  Dict				,						a					:  Dict				,						a					:  List[Any]				,						a					:  Tuple				,						a					:  Dict				,						a					:  Union[str, Any]				,						a					:  Dict				,						a					:  Any				,						a					:  Dict				,						)						->Tuple:
													SCREAMING_SNAKE_CASE__  :					Dict =       self.num_labels
													SCREAMING_SNAKE_CASE__  :					int =       FunnelForPreTraining(config=a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       model(a				,						attention_mask=a				,						token_type_ids=a				,						labels=a     )
													self.parent.assertEqual(result.logits.shape				,						(self.batch_size, self.seq_length)     )

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

							def   A_	(   self					:  Any				,						a					:  Any				,						a					:  List[Any]				,						a					:  Union[str, Any]				,						a					:  Optional[int]				,						a					:  Optional[int]				,						a					:  str				,						a					:  Union[str, Any]				,						a					:  str				,						)						->List[str]:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.num_labels
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       FunnelForSequenceClassification(a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					Any =       model(a				,						attention_mask=a				,						token_type_ids=a				,						labels=a     )
													self.parent.assertEqual(result.logits.shape				,						(self.batch_size, self.num_labels)     )

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

							def   A_	(   self					:  Dict				,						a					:  Union[str, Any]				,						a					:  Union[str, Any]				,						a					:  Tuple				,						a					:  Union[str, Any]				,						a					:  Optional[int]				,						a					:  Union[str, Any]				,						a					:  Optional[int]				,						a					:  Optional[Any]				,						)						->Tuple:
													SCREAMING_SNAKE_CASE__  :					int =       self.num_labels
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FunnelForTokenClassification(config=a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       model(a				,						attention_mask=a				,						token_type_ids=a				,						labels=a     )
													self.parent.assertEqual(result.logits.shape				,						(self.batch_size, self.seq_length, self.num_labels)     )

							def   A_	(   self					:  Dict				,						a					:  Any				,						a					:  List[str]				,						a					:  Dict				,						a					:  Tuple				,						a					:  Optional[Any]				,						a					:  str				,						a					:  List[str]				,						a					:  List[str]				,						)						->List[Any]:
													SCREAMING_SNAKE_CASE__  :					Any =       FunnelForQuestionAnswering(config=a     )
													model.to(a     )
													model.eval()
													SCREAMING_SNAKE_CASE__  :					str =       model(
													    a				,						attention_mask=a				,						token_type_ids=a				,						start_positions=a				,						end_positions=a				,						)
													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   A_	(   self					:  Tuple     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       self.prepare_config_and_inputs()
													(
													    (
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				(
													    SCREAMING_SNAKE_CASE__
													),				
													)  :					Dict =       config_and_inputs
													SCREAMING_SNAKE_CASE__  :					List[Any] =       {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
													return config, inputs_dict







@require_torch
class  _a  (					lowercase__       ,				lowercase__       ,				unittest.TestCase				):






							"""simple docstring"""

							snake_case_							=    False
							snake_case_							=    False
							snake_case_							=    (
							    (
							        FunnelModel,
							        FunnelForMaskedLM,
							        FunnelForPreTraining,
							        FunnelForQuestionAnswering,
							        FunnelForTokenClassification,
							    )
							    if is_torch_available()
							    else ()
							)
							snake_case_							=    (
							    {
							        "feature-extraction": (FunnelBaseModel, FunnelModel),
							        "fill-mask": FunnelForMaskedLM,
							        "question-answering": FunnelForQuestionAnswering,
							        "text-classification": FunnelForSequenceClassification,
							        "token-classification": FunnelForTokenClassification,
							        "zero-shot": FunnelForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)

							def   A_	(   self					:  List[str]				,						a					:  Tuple				,						a					:  List[str]				,						a					:  Tuple=False     )						->Optional[int]:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       super()._prepare_for_class(a				,						a				,						return_labels=a     )

													if return_labels:
																			if model_class in get_values(a     ):
																									SCREAMING_SNAKE_CASE__  :					int =       torch.zeros(
																									    (self.model_tester.batch_size, self.model_tester.seq_length)				,						dtype=torch.long				,						device=a     )
													return inputs_dict

							def   A_	(   self					:  Optional[Any]     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FunnelModelTester(self     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       ConfigTester(self				,						config_class=a     )

							def   A_	(   self					:  Tuple     )						->Union[str, Any]:
													self.config_tester.run_common_tests()

							def   A_	(   self					:  Dict     )						->List[str]:
													SCREAMING_SNAKE_CASE__  :					Any =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*a     )

							def   A_	(   self					:  Optional[Any]     )						->str:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_pretraining(*a     )

							def   A_	(   self					:  Dict     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					List[Any] =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_masked_lm(*a     )

							def   A_	(   self					:  Optional[Any]     )						->str:
													SCREAMING_SNAKE_CASE__  :					List[str] =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_token_classification(*a     )

							def   A_	(   self					:  Dict     )						->Any:
													SCREAMING_SNAKE_CASE__  :					int =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_question_answering(*a     )






							def   A_	(   self					:  List[str]				,						a					:  Dict     )						->Union[str, Any]:
													if hasattr(a				,						"weight"     ) and module.weight is not None:
																			module.weight.data.fill_(3     )
													if hasattr(a				,						"bias"     ) and module.bias is not None:
																			module.bias.data.fill_(3     )

													for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
																			if hasattr(a				,						a     ) and getattr(a				,						a     ) is not None:
																									SCREAMING_SNAKE_CASE__  :					str =       getattr(a				,						a     )
																									weight.data.fill_(3     )







@require_torch
class  _a  (					lowercase__       ,				unittest.TestCase				):






							"""simple docstring"""

							snake_case_							=    False
							snake_case_							=    False
							snake_case_							=    (
							    (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
							)

							def   A_	(   self					:  List[str]     )						->int:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FunnelModelTester(self				,						base=a     )
													SCREAMING_SNAKE_CASE__  :					Any =       ConfigTester(self				,						config_class=a     )

							def   A_	(   self					:  Any     )						->Optional[int]:
													self.config_tester.run_common_tests()

							def   A_	(   self					:  Dict     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_base_model(*a     )

							def   A_	(   self					:  List[str]     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					List[str] =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_sequence_classification(*a     )

							def   A_	(   self					:  List[Any]     )						->List[str]:
													SCREAMING_SNAKE_CASE__  :					Dict =       self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_multiple_choice(*a     )

							def   A_	(   self					:  Optional[Any]     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					Tuple =       self.model_tester.prepare_config_and_inputs_for_common()
													SCREAMING_SNAKE_CASE__  :					Tuple =       True

													for model_class in self.all_model_classes:
																			if model_class.__name__ == "FunnelBaseModel":
																									continue
																			SCREAMING_SNAKE_CASE__  :					int =       model_class(a     )
																			model.to(a     )
																			model.train()
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       self._prepare_for_class(a				,						a				,						return_labels=a     )
																			SCREAMING_SNAKE_CASE__  :					Optional[int] =       model(**a     ).loss
																			loss.backward()






							def   A_	(   self					:  Optional[Any]				,						a					:  Optional[int]     )						->int:
													if hasattr(a				,						"weight"     ) and module.weight is not None:
																			module.weight.data.fill_(3     )
													if hasattr(a				,						"bias"     ) and module.bias is not None:
																			module.bias.data.fill_(3     )

													for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
																			if hasattr(a				,						a     ) and getattr(a				,						a     ) is not None:
																									SCREAMING_SNAKE_CASE__  :					Optional[int] =       getattr(a				,						a     )
																									weight.data.fill_(3     )







@require_torch
@require_sentencepiece
@require_tokenizers
class  _a  (					unittest.TestCase				):






							"""simple docstring"""

							def   A_	(   self					:  str     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       13
													SCREAMING_SNAKE_CASE__  :					int =       7
													SCREAMING_SNAKE_CASE__  :					Any =       torch.arange(0				,						batch_size * sequence_length     ).long().reshape(a				,						a     )
													SCREAMING_SNAKE_CASE__  :					Any =       [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
													SCREAMING_SNAKE_CASE__  :					List[Any] =       torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]     )

													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       FunnelModel.from_pretrained("sgugger/funnel-random-tiny"     )
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       model(a				,						token_type_ids=a     )[0].abs()

													SCREAMING_SNAKE_CASE__  :					Optional[int] =       torch.tensor(2344.8352     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       torch.tensor(0.8052     )
													self.assertTrue(torch.allclose(output.sum()				,						a				,						atol=1E-4     )     )
													self.assertTrue(torch.allclose(output.mean()				,						a				,						atol=1E-4     )     )

													SCREAMING_SNAKE_CASE__  :					Dict =       torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]     )
													SCREAMING_SNAKE_CASE__  :					int =       model(a				,						attention_mask=a				,						token_type_ids=a     )[0].abs()

													SCREAMING_SNAKE_CASE__  :					List[Any] =       torch.tensor(2343.8425     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       torch.tensor(0.8049     )
													self.assertTrue(torch.allclose(output.sum()				,						a				,						atol=1E-4     )     )
													self.assertTrue(torch.allclose(output.mean()				,						a				,						atol=1E-4     )     )






							@slow
							def   A_	(   self					:  str     )						->Optional[Any]:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FunnelTokenizer.from_pretrained("huggingface/funnel-small"     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       FunnelModel.from_pretrained("huggingface/funnel-small"     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       tokenizer("Hello! I am the Funnel Transformer model."				,						return_tensors="pt"     )
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       model(**a     )[0]

													SCREAMING_SNAKE_CASE__  :					Optional[int] =       torch.tensor(235.7246     )
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       torch.tensor(0.0256     )
													self.assertTrue(torch.allclose(output.sum()				,						a				,						atol=1E-4     )     )
													self.assertTrue(torch.allclose(output.mean()				,						a				,						atol=1E-4     )     )






from __future__ import annotations

from enum import Enum, unique
from typing import TypeVar

# Create a generic variable that can be 'Enum', or any subclass.
__lowercase							:List[Any]							=	TypeVar("T", bound="Enum")



@unique
class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    80
							snake_case_							=    70
							snake_case_							=    60
							snake_case_							=    50
							snake_case_							=    40
							snake_case_							=    30
							snake_case_							=    20
							snake_case_							=    10







@unique
class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    24
							snake_case_							=    21
							snake_case_							=    18
							snake_case_							=    15
							snake_case_							=    12
							snake_case_							=    9
							snake_case_							=    6
							snake_case_							=    3
							snake_case_							=    2
							snake_case_							=    1
							snake_case_							=    -1
							snake_case_							=    -2
							snake_case_							=    -3
							snake_case_							=    -6
							snake_case_							=    -9
							snake_case_							=    -12
							snake_case_							=    -15
							snake_case_							=    -18
							snake_case_							=    -21
							snake_case_							=    -24

							@classmethod
							def   A_	(   cls					:  type[T]     )						->dict:
													return {unit.name: unit.value for unit in cls if unit.value > 0}






							@classmethod
							def   A_	(   cls					:  type[T]     )						->dict:
													return {unit.name: unit.value for unit in cls if unit.value < 0}







def    UpperCAmelCase				(  _lowerCamelCase   :	float  ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__  :					str =       SIUnit.get_positive() if value > 0 else SIUnit.get_negative()
						for name_prefix, value_prefix in prefixes.items():
												SCREAMING_SNAKE_CASE__  :					str =       value / (10**value_prefix)
												if numerical_part > 1:
																		return f"""{numerical_part!s} {name_prefix}"""
						return str(_lowerCamelCase  )







def    UpperCAmelCase				(  _lowerCamelCase   :	float  ):





						'''simple docstring'''


						for prefix in BinaryUnit:
												SCREAMING_SNAKE_CASE__  :					List[Any] =       value / (2**prefix.value)
												if numerical_part > 1:
																		return f"""{numerical_part!s} {prefix.name}"""
						return str(_lowerCamelCase  )


if __name__ == "__main__":
				import doctest

				doctest.testmod()