from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


lowerCAmelCase__							= {
    'configuration_gptsan_japanese': ['GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTSanJapaneseConfig'],
    'tokenization_gptsan_japanese': ['GPTSanJapaneseTokenizer'],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase__							= [
        'GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST',
        'GPTSanJapaneseForConditionalGeneration',
        'GPTSanJapaneseModel',
        'GPTSanJapanesePreTrainedModel',
    ]
    lowerCAmelCase__							= [
        'GPTSanJapaneseTokenizer',
    ]


if TYPE_CHECKING:
    from .configuration_gptsan_japanese import GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTSanJapaneseConfig
    from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_gptsan_japanese import (
            GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
            GPTSanJapaneseForConditionalGeneration,
            GPTSanJapaneseModel,
            GPTSanJapanesePreTrainedModel,
        )
        from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer


else:
    import sys

    lowerCAmelCase__							= _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

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  _UpperCAmelCase       :



 '''simple docstring'''




 def __init__(						self							:					List[Any]				,      lowercase_							:					Optional[int]				,      lowercase_							:					Optional[Any]=13				,      lowercase_							:					str=7				,      lowercase_							:					int=True				,      lowercase_							:					Optional[Any]=True				,      lowercase_							:					Tuple=True				,      lowercase_							:					int=True				,      lowercase_							:					Optional[Any]=99				,      lowercase_							:					Any=[1, 1, 2]				,      lowercase_							:					List[str]=1				,      lowercase_							:					Optional[Any]=32				,      lowercase_							:					List[str]=4				,      lowercase_							:					Optional[int]=8				,      lowercase_							:					Tuple=37				,      lowercase_							:					Any="gelu_new"				,      lowercase_							:					List[str]=0.1				,      lowercase_							:					List[str]=0.1				,      lowercase_							:					str=0.0				,      lowercase_							:					List[str]=512				,      lowercase_							:					int=3				,      lowercase_							:					Optional[Any]=0.02				,      lowercase_							:					Any=3				,      lowercase_							:					Optional[Any]=4				,      lowercase_							:					Dict=None				,      lowercase_							:					Dict=False				,      )		->     List[str]:


   """simple docstring"""







   _UpperCamelCase				=  parent
   _UpperCamelCase				=  batch_size
   _UpperCamelCase				=  seq_length
   _UpperCamelCase				=  is_training
   _UpperCamelCase				=  use_input_mask
   _UpperCamelCase				=  use_token_type_ids
   _UpperCamelCase				=  use_labels
   _UpperCamelCase				=  vocab_size
   _UpperCamelCase				=  block_sizes
   _UpperCamelCase				=  num_decoder_layers
   _UpperCamelCase				=  d_model
   _UpperCamelCase				=  n_head
   _UpperCamelCase				=  d_head
   _UpperCamelCase				=  d_inner
   _UpperCamelCase				=  hidden_act
   _UpperCamelCase				=  hidden_dropout
   _UpperCamelCase				=  attention_dropout
   _UpperCamelCase				=  activation_dropout
   _UpperCamelCase				=  max_position_embeddings
   _UpperCamelCase				=  type_vocab_size
   _UpperCamelCase				=  2
   _UpperCamelCase				=  num_labels
   _UpperCamelCase				=  num_choices
   _UpperCamelCase				=  scope
   _UpperCamelCase				=  initializer_std

   # Used in the tests to check the size of the first attention layer
   _UpperCamelCase				=  n_head
   # Used in the tests to check the size of the first hidden state
   _UpperCamelCase				=  self.d_model
   # Used in the tests to check the number of output hidden states/attentions
   _UpperCamelCase				=  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:
     _UpperCamelCase				=  self.num_hidden_layers + 2







 def 						__UpperCAmelCase							(						self							:					Union[str, Any])		->     Optional[Any]:


   """simple docstring"""







   _UpperCamelCase				=  ids_tensor([self.batch_size, self.seq_length]				,      self.vocab_size)

   _UpperCamelCase				=  None
   if self.use_input_mask:
     _UpperCamelCase				=  ids_tensor([self.batch_size, self.seq_length]				,      vocab_size=2)

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

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

   _UpperCamelCase				=  self.get_config()

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







 def 						__UpperCAmelCase							(						self							:					Tuple)		->     Union[str, 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 						__UpperCAmelCase							(						self							:					Union[str, Any]				,      lowercase_							:					str				,      lowercase_							:					Dict				,      lowercase_							:					List[Any]				,      lowercase_							:					Union[str, Any]				,      lowercase_							:					str				,      lowercase_							:					List[Any]				,      lowercase_							:					List[str]				,      lowercase_							:					Optional[Any]				,      )		->     Optional[int]:


   """simple docstring"""







   _UpperCamelCase				=  FunnelModel(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_)
   _UpperCamelCase				=  model(lowercase_				,      token_type_ids=lowercase_)
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, self.seq_length, self.d_model))

   _UpperCamelCase				=  False
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, self.seq_length, self.d_model))

   _UpperCamelCase				=  False
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, self.seq_length, self.d_model))







 def 						__UpperCAmelCase							(						self							:					Optional[int]				,      lowercase_							:					str				,      lowercase_							:					Optional[Any]				,      lowercase_							:					Optional[int]				,      lowercase_							:					Union[str, Any]				,      lowercase_							:					List[str]				,      lowercase_							:					List[Any]				,      lowercase_							:					Any				,      lowercase_							:					Any				,      )		->     List[Any]:


   """simple docstring"""







   _UpperCamelCase				=  FunnelBaseModel(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_)
   _UpperCamelCase				=  model(lowercase_				,      token_type_ids=lowercase_)
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, 2, self.d_model))

   _UpperCamelCase				=  False
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, 3, self.d_model))

   _UpperCamelCase				=  False
   _UpperCamelCase				=  model(lowercase_)
   self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, 2, self.d_model))







 def 						__UpperCAmelCase							(						self							:					Dict				,      lowercase_							:					Tuple				,      lowercase_							:					List[str]				,      lowercase_							:					Any				,      lowercase_							:					Any				,      lowercase_							:					Optional[Any]				,      lowercase_							:					Optional[Any]				,      lowercase_							:					List[Any]				,      lowercase_							:					Optional[int]				,      )		->     List[str]:


   """simple docstring"""







   _UpperCamelCase				=  self.num_labels
   _UpperCamelCase				=  FunnelForPreTraining(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      labels=lowercase_)
   self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.seq_length))







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


   """simple docstring"""







   _UpperCamelCase				=  FunnelForMaskedLM(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      labels=lowercase_)
   self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.seq_length, self.vocab_size))







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


   """simple docstring"""







   _UpperCamelCase				=  self.num_labels
   _UpperCamelCase				=  FunnelForSequenceClassification(lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      labels=lowercase_)
   self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.num_labels))







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


   """simple docstring"""







   _UpperCamelCase				=  self.num_choices
   _UpperCamelCase				=  FunnelForMultipleChoice(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  input_ids.unsqueeze(1).expand(-1				,      self.num_choices				,      -1).contiguous()
   _UpperCamelCase				=  token_type_ids.unsqueeze(1).expand(-1				,      self.num_choices				,      -1).contiguous()
   _UpperCamelCase				=  input_mask.unsqueeze(1).expand(-1				,      self.num_choices				,      -1).contiguous()
   _UpperCamelCase				=  model(
       lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      labels=lowercase_				,      )
   self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.num_choices))







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


   """simple docstring"""







   _UpperCamelCase				=  self.num_labels
   _UpperCamelCase				=  FunnelForTokenClassification(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      labels=lowercase_)
   self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.seq_length, self.num_labels))







 def 						__UpperCAmelCase							(						self							:					str				,      lowercase_							:					Tuple				,      lowercase_							:					Optional[int]				,      lowercase_							:					str				,      lowercase_							:					List[Any]				,      lowercase_							:					Any				,      lowercase_							:					Dict				,      lowercase_							:					str				,      lowercase_							:					Optional[Any]				,      )		->     Dict:


   """simple docstring"""







   _UpperCamelCase				=  FunnelForQuestionAnswering(config=lowercase_)
   model.to(lowercase_)
   model.eval()
   _UpperCamelCase				=  model(
       lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_				,      start_positions=lowercase_				,      end_positions=lowercase_				,      )
   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 						__UpperCAmelCase							(						self							:					Tuple)		->     int:


   """simple docstring"""







   _UpperCamelCase				=  self.prepare_config_and_inputs()
   (
       (
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		(
       _UpperCamelCase
   )	,		
   )				=  config_and_inputs
   _UpperCamelCase				=  {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
   return config, inputs_dict




@require_torch
class  _UpperCAmelCase       (			lowerCAmelCase,       lowerCAmelCase,       unittest.TestCase   ):



 '''simple docstring'''




 __A           = False
 __A           = False
 __A           = (
     (
         FunnelModel,
         FunnelForMaskedLM,
         FunnelForPreTraining,
         FunnelForQuestionAnswering,
         FunnelForTokenClassification,
     )
     if is_torch_available()
     else ()
 )
 __A           = (
     {
         '''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 						__UpperCAmelCase							(						self							:					int				,      lowercase_							:					str				,      lowercase_							:					Optional[Any]				,      lowercase_							:					Union[str, Any]=False)		->     List[Any]:


   """simple docstring"""







   _UpperCamelCase				=  super()._prepare_for_class(lowercase_				,      lowercase_				,      return_labels=lowercase_)

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







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


   """simple docstring"""







   _UpperCamelCase				=  FunnelModelTester(self)
   _UpperCamelCase				=  ConfigTester(self				,      config_class=lowercase_)







 def 						__UpperCAmelCase							(						self							:					Dict)		->     Optional[int]:


   """simple docstring"""







   self.config_tester.run_common_tests()







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


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_model(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					str)		->     str:


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_pretraining(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					int)		->     Optional[int]:


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_masked_lm(*lowercase_)







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


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_token_classification(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					Optional[Any])		->     Dict:


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_question_answering(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					Any				,      lowercase_							:					Tuple)		->     Optional[int]:


   """simple docstring"""







   if hasattr(lowercase_				,      "weight") and module.weight is not None:
     module.weight.data.fill_(3)
   if hasattr(lowercase_				,      "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(lowercase_				,      lowercase_) and getattr(lowercase_				,      lowercase_) is not None:
       _UpperCamelCase				=  getattr(lowercase_				,      lowercase_)
       weight.data.fill_(3)




@require_torch
class  _UpperCAmelCase       (			lowerCAmelCase,       unittest.TestCase   ):



 '''simple docstring'''




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







 def 						__UpperCAmelCase							(						self							:					Dict)		->     Dict:


   """simple docstring"""







   _UpperCamelCase				=  FunnelModelTester(self				,      base=lowercase_)
   _UpperCamelCase				=  ConfigTester(self				,      config_class=lowercase_)







 def 						__UpperCAmelCase							(						self							:					Dict)		->     int:


   """simple docstring"""







   self.config_tester.run_common_tests()







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


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_base_model(*lowercase_)







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


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_sequence_classification(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					Tuple)		->     Optional[Any]:


   """simple docstring"""







   _UpperCamelCase				=  self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_multiple_choice(*lowercase_)







 def 						__UpperCAmelCase							(						self							:					Tuple)		->     Dict:


   """simple docstring"""







   _UpperCamelCase	,		_UpperCamelCase				=  self.model_tester.prepare_config_and_inputs_for_common()
   _UpperCamelCase				=  True

   for model_class in self.all_model_classes:
     if model_class.__name__ == "FunnelBaseModel":
       continue
     _UpperCamelCase				=  model_class(lowercase_)
     model.to(lowercase_)
     model.train()
     _UpperCamelCase				=  self._prepare_for_class(lowercase_				,      lowercase_				,      return_labels=lowercase_)
     _UpperCamelCase				=  model(**lowercase_).loss
     loss.backward()







 def 						__UpperCAmelCase							(						self							:					str				,      lowercase_							:					Optional[int])		->     Optional[Any]:


   """simple docstring"""







   if hasattr(lowercase_				,      "weight") and module.weight is not None:
     module.weight.data.fill_(3)
   if hasattr(lowercase_				,      "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(lowercase_				,      lowercase_) and getattr(lowercase_				,      lowercase_) is not None:
       _UpperCamelCase				=  getattr(lowercase_				,      lowercase_)
       weight.data.fill_(3)




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



 '''simple docstring'''




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


   """simple docstring"""







   _UpperCamelCase				=  13
   _UpperCamelCase				=  7
   _UpperCamelCase				=  torch.arange(0				,      batch_size * sequence_length).long().reshape(lowercase_				,      lowercase_)
   _UpperCamelCase				=  [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
   _UpperCamelCase				=  torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths])

   _UpperCamelCase				=  FunnelModel.from_pretrained("sgugger/funnel-random-tiny")
   _UpperCamelCase				=  model(lowercase_				,      token_type_ids=lowercase_)[0].abs()

   _UpperCamelCase				=  torch.tensor(23_44.83_52)
   _UpperCamelCase				=  torch.tensor(0.80_52)
   self.assertTrue(torch.allclose(output.sum()				,      lowercase_				,      atol=1e-4))
   self.assertTrue(torch.allclose(output.mean()				,      lowercase_				,      atol=1e-4))

   _UpperCamelCase				=  torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]])
   _UpperCamelCase				=  model(lowercase_				,      attention_mask=lowercase_				,      token_type_ids=lowercase_)[0].abs()

   _UpperCamelCase				=  torch.tensor(23_43.84_25)
   _UpperCamelCase				=  torch.tensor(0.80_49)
   self.assertTrue(torch.allclose(output.sum()				,      lowercase_				,      atol=1e-4))
   self.assertTrue(torch.allclose(output.mean()				,      lowercase_				,      atol=1e-4))







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


   """simple docstring"""







   _UpperCamelCase				=  FunnelTokenizer.from_pretrained("huggingface/funnel-small")
   _UpperCamelCase				=  FunnelModel.from_pretrained("huggingface/funnel-small")
   _UpperCamelCase				=  tokenizer("Hello! I am the Funnel Transformer model."				,      return_tensors="pt")
   _UpperCamelCase				=  model(**lowercase_)[0]

   _UpperCamelCase				=  torch.tensor(2_35.72_46)
   _UpperCamelCase				=  torch.tensor(0.02_56)
   self.assertTrue(torch.allclose(output.sum()				,      lowercase_				,      atol=1e-4))
   self.assertTrue(torch.allclose(output.mean()				,      lowercase_				,      atol=1e-4))




