code: 
  '''simple docstring'''
  
  
  
  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							:
  
  
  
  			def __init__(					self       ,     lowerCamelCase__       ,     lowerCamelCase__=13       ,     lowerCamelCase__=7       ,     lowerCamelCase__=True       ,     lowerCamelCase__=True       ,     lowerCamelCase__=True       ,     lowerCamelCase__=True       ,     lowerCamelCase__=99       ,     lowerCamelCase__=[1, 1, 2]       ,     lowerCamelCase__=1       ,     lowerCamelCase__=32       ,     lowerCamelCase__=4       ,     lowerCamelCase__=8       ,     lowerCamelCase__=37       ,     lowerCamelCase__="gelu_new"       ,     lowerCamelCase__=0.1       ,     lowerCamelCase__=0.1       ,     lowerCamelCase__=0.0       ,     lowerCamelCase__=512       ,     lowerCamelCase__=3       ,     lowerCamelCase__=0.02       ,     lowerCamelCase__=3       ,     lowerCamelCase__=4       ,     lowerCamelCase__=None       ,     lowerCamelCase__=False       ,     )			->		Any:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       parent
  									lowercase__							 =       batch_size
  									lowercase__							 =       seq_length
  									lowercase__							 =       is_training
  									lowercase__							 =       use_input_mask
  									lowercase__							 =       use_token_type_ids
  									lowercase__							 =       use_labels
  									lowercase__							 =       vocab_size
  									lowercase__							 =       block_sizes
  									lowercase__							 =       num_decoder_layers
  									lowercase__							 =       d_model
  									lowercase__							 =       n_head
  									lowercase__							 =       d_head
  									lowercase__							 =       d_inner
  									lowercase__							 =       hidden_act
  									lowercase__							 =       hidden_dropout
  									lowercase__							 =       attention_dropout
  									lowercase__							 =       activation_dropout
  									lowercase__							 =       max_position_embeddings
  									lowercase__							 =       type_vocab_size
  									lowercase__							 =       2
  									lowercase__							 =       num_labels
  									lowercase__							 =       num_choices
  									lowercase__							 =       scope
  									lowercase__							 =       initializer_std
  
  									# Used in the tests to check the size of the first attention layer
  									lowercase__							 =       n_head
  									# Used in the tests to check the size of the first hidden state
  									lowercase__							 =       self.d_model
  									# Used in the tests to check the number of output hidden states/attentions
  									lowercase__							 =       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:
  															lowercase__							 =       self.num_hidden_layers + 2
  
  
  
  			def A__ (					self       )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       ids_tensor([self.batch_size, self.seq_length]       ,     self.vocab_size       )
  
  									lowercase__							 =       None
  									if self.use_input_mask:
  															lowercase__							 =       ids_tensor([self.batch_size, self.seq_length]       ,     vocab_size=2       )
  
  									lowercase__							 =       None
  									if self.use_token_type_ids:
  															lowercase__							 =       ids_tensor([self.batch_size, self.seq_length]       ,     self.type_vocab_size       )
  
  									lowercase__							 =       None
  									lowercase__							 =       None
  									lowercase__							 =       None
  									if self.use_labels:
  															lowercase__							 =       ids_tensor([self.batch_size]       ,     self.type_sequence_label_size       )
  															lowercase__							 =       ids_tensor([self.batch_size, self.seq_length]       ,     self.num_labels       )
  															lowercase__							 =       ids_tensor([self.batch_size]       ,     self.num_choices       )
  															lowercase__							 =       ids_tensor([self.batch_size, self.seq_length]       ,     1       )
  
  									lowercase__							 =       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]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									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       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelModel(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       model(lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )
  									lowercase__							 =       model(lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, self.seq_length, self.d_model)       )
  
  									lowercase__							 =       False
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, self.seq_length, self.d_model)       )
  
  									lowercase__							 =       False
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, self.seq_length, self.d_model)       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		str:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelBaseModel(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       model(lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )
  									lowercase__							 =       model(lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, 2, self.d_model)       )
  
  									lowercase__							 =       False
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, 3, self.d_model)       )
  
  									lowercase__							 =       False
  									lowercase__							 =       model(lowerCAmelCase__       )
  									self.parent.assertEqual(result.last_hidden_state.shape       ,     (self.batch_size, 2, self.d_model)       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.num_labels
  									lowercase__							 =       FunnelForPreTraining(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       model(lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       ,     labels=lowerCAmelCase__       )
  									self.parent.assertEqual(result.logits.shape       ,     (self.batch_size, self.seq_length)       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Tuple:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelForMaskedLM(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       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 A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Dict:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.num_labels
  									lowercase__							 =       FunnelForSequenceClassification(lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       model(lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       ,     labels=lowerCAmelCase__       )
  									self.parent.assertEqual(result.logits.shape       ,     (self.batch_size, self.num_labels)       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Optional[Any]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.num_choices
  									lowercase__							 =       FunnelForMultipleChoice(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       input_ids.unsqueeze(1       ).expand(-1       ,     self.num_choices       ,     -1       ).contiguous()
  									lowercase__							 =       token_type_ids.unsqueeze(1       ).expand(-1       ,     self.num_choices       ,     -1       ).contiguous()
  									lowercase__							 =       input_mask.unsqueeze(1       ).expand(-1       ,     self.num_choices       ,     -1       ).contiguous()
  									lowercase__							 =       model(
  									    lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       ,     labels=lowerCAmelCase__       ,     )
  									self.parent.assertEqual(result.logits.shape       ,     (self.batch_size, self.num_choices)       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		Tuple:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.num_labels
  									lowercase__							 =       FunnelForTokenClassification(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       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 A__ (					self       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     )			->		str:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelForQuestionAnswering(config=lowerCAmelCase__       )
  									model.to(lowerCAmelCase__       )
  									model.eval()
  									lowercase__							 =       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 A__ (					self       )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.prepare_config_and_inputs()
  									(
  									    lowercase__							
  									)							 =       config_and_inputs
  									lowercase__							 =       {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
  									return config, inputs_dict
  
  
  
  
  
  @require_torch
  class 			A							(       UpperCamelCase__		,						UpperCamelCase__		,						unittest.TestCase				):
  			lowerCamelCase							:							Optional[Any]       		=  False
  			lowerCamelCase							:							int       		=  False
  			lowerCamelCase							:							Optional[int]       		=  (
  			    (
  			        FunnelModel,
  			        FunnelForMaskedLM,
  			        FunnelForPreTraining,
  			        FunnelForQuestionAnswering,
  			        FunnelForTokenClassification,
  			    )
  			    if is_torch_available()
  			    else ()
  			)
  			lowerCamelCase							:							List[str]       		=  (
  			    {
  			        """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       ,     lowerCamelCase__       ,     lowerCamelCase__       ,     lowerCamelCase__=False       )			->		List[str]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       super()._prepare_for_class(lowerCAmelCase__       ,     lowerCAmelCase__       ,     return_labels=lowerCAmelCase__       )
  
  									if return_labels:
  															if model_class in get_values(lowerCAmelCase__       ):
  																					lowercase__							 =       torch.zeros(
  																					    (self.model_tester.batch_size, self.model_tester.seq_length)       ,     dtype=torch.long       ,     device=lowerCAmelCase__       )
  									return inputs_dict
  
  
  
  			def A__ (					self       )			->		List[str]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelModelTester(self       )
  									lowercase__							 =       ConfigTester(self       ,     config_class=lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		List[str]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									self.config_tester.run_common_tests()
  
  
  
  			def A__ (					self       )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_model(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		List[str]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_pretraining(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		Optional[int]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		List[Any]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		Tuple:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       )			->		Optional[Any]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									if hasattr(lowerCAmelCase__       ,     """weight"""       ) and module.weight is not None:
  															module.weight.data.fill_(3       )
  									if hasattr(lowerCAmelCase__       ,     """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(lowerCAmelCase__       ,     lowerCAmelCase__       ) and getattr(lowerCAmelCase__       ,     lowerCAmelCase__       ) is not None:
  																					lowercase__							 =       getattr(lowerCAmelCase__       ,     lowerCAmelCase__       )
  																					weight.data.fill_(3       )
  
  
  
  
  
  @require_torch
  class 			A							(       UpperCamelCase__		,						unittest.TestCase				):
  			lowerCamelCase							:							Tuple       		=  False
  			lowerCamelCase							:							List[str]       		=  False
  			lowerCamelCase							:							str       		=  (
  			    (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
  			)
  
  
  
  			def A__ (					self       )			->		List[Any]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelModelTester(self       ,     base=lowerCAmelCase__       )
  									lowercase__							 =       ConfigTester(self       ,     config_class=lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		List[str]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									self.config_tester.run_common_tests()
  
  
  
  			def A__ (					self       )			->		Tuple:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_base_model(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		Any:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		int:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_multiple_choice(*lowerCAmelCase__       )
  
  
  
  			def A__ (					self       )			->		int:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       self.model_tester.prepare_config_and_inputs_for_common()
  									lowercase__							 =       True
  
  									for model_class in self.all_model_classes:
  															if model_class.__name__ == "FunnelBaseModel":
  																					continue
  															lowercase__							 =       model_class(lowerCAmelCase__       )
  															model.to(lowerCAmelCase__       )
  															model.train()
  															lowercase__							 =       self._prepare_for_class(lowerCAmelCase__       ,     lowerCAmelCase__       ,     return_labels=lowerCAmelCase__       )
  															lowercase__							 =       model(**lowerCAmelCase__       ).loss
  															loss.backward()
  
  
  
  			def A__ (					self       ,     lowerCamelCase__       )			->		str:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									if hasattr(lowerCAmelCase__       ,     """weight"""       ) and module.weight is not None:
  															module.weight.data.fill_(3       )
  									if hasattr(lowerCAmelCase__       ,     """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(lowerCAmelCase__       ,     lowerCAmelCase__       ) and getattr(lowerCAmelCase__       ,     lowerCAmelCase__       ) is not None:
  																					lowercase__							 =       getattr(lowerCAmelCase__       ,     lowerCAmelCase__       )
  																					weight.data.fill_(3       )
  
  
  
  
  
  @require_torch
  @require_sentencepiece
  @require_tokenizers
  class 			A							(       unittest.TestCase				):
  
  
  
  			def A__ (					self       )			->		Optional[Any]:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       13
  									lowercase__							 =       7
  									lowercase__							 =       torch.arange(0       ,     batch_size * sequence_length       ).long().reshape(lowerCAmelCase__       ,     lowerCAmelCase__       )
  									lowercase__							 =       [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
  									lowercase__							 =       torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]       )
  
  									lowercase__							 =       FunnelModel.from_pretrained("""sgugger/funnel-random-tiny"""       )
  									lowercase__							 =       model(lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )[0].abs()
  
  									lowercase__							 =       torch.tensor(2_344.8_352       )
  									lowercase__							 =       torch.tensor(0.80_52       )
  									self.assertTrue(torch.allclose(output.sum()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  									self.assertTrue(torch.allclose(output.mean()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  
  									lowercase__							 =       torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]       )
  									lowercase__							 =       model(lowerCAmelCase__       ,     attention_mask=lowerCAmelCase__       ,     token_type_ids=lowerCAmelCase__       )[0].abs()
  
  									lowercase__							 =       torch.tensor(2_343.8_425       )
  									lowercase__							 =       torch.tensor(0.80_49       )
  									self.assertTrue(torch.allclose(output.sum()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  									self.assertTrue(torch.allclose(output.mean()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  
  
  
  			@slow
  			def A__ (					self       )			->		str:
  
  
  
  
  									'''simple docstring'''
  
  
  
  									lowercase__							 =       FunnelTokenizer.from_pretrained("""huggingface/funnel-small"""       )
  									lowercase__							 =       FunnelModel.from_pretrained("""huggingface/funnel-small"""       )
  									lowercase__							 =       tokenizer("""Hello! I am the Funnel Transformer model."""       ,     return_tensors="""pt"""       )
  									lowercase__							 =       model(**lowerCAmelCase__       )[0]
  
  									lowercase__							 =       torch.tensor(235.7_246       )
  									lowercase__							 =       torch.tensor(0.02_56       )
  									self.assertTrue(torch.allclose(output.sum()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  									self.assertTrue(torch.allclose(output.mean()       ,     lowerCAmelCase__       ,     atol=1e-4       )       )
  
  
  
  
  
  
  
style_context: 
  '''simple docstring'''
  
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  
  
  __A          =    {"configuration_detr": ["DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetrConfig", "DetrOnnxConfig"]}
  
  try:
  				if not is_vision_available():
  								raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
  				pass
  else:
  				__A          =    ["DetrFeatureExtractor"]
  				__A          =    ["DetrImageProcessor"]
  
  try:
  				if not is_torch_available():
  								raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
  				pass
  else:
  				__A          =    [
  				    "DETR_PRETRAINED_MODEL_ARCHIVE_LIST",
  				    "DetrForObjectDetection",
  				    "DetrForSegmentation",
  				    "DetrModel",
  				    "DetrPreTrainedModel",
  				]
  
  
  if TYPE_CHECKING:
  				from .configuration_detr import DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DetrConfig, DetrOnnxConfig
  
  				try:
  								if not is_vision_available():
  												raise OptionalDependencyNotAvailable()
  				except OptionalDependencyNotAvailable:
  								pass
  				else:
  								from .feature_extraction_detr import DetrFeatureExtractor
  								from .image_processing_detr import DetrImageProcessor
  
  				try:
  								if not is_torch_available():
  												raise OptionalDependencyNotAvailable()
  				except OptionalDependencyNotAvailable:
  								pass
  				else:
  								from .modeling_detr import (
  								    DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
  								    DetrForObjectDetection,
  								    DetrForSegmentation,
  								    DetrModel,
  								    DetrPreTrainedModel,
  								)
  
  else:
  				import sys
  
  				__A          =    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
  
  
  
  
  
  
  