






"""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				:    int    ,     __lowerCamelCase				:    int    ,     __lowerCamelCase				:    Optional[int]=1_3    ,     __lowerCamelCase				:    Union[str, Any]=7    ,     __lowerCamelCase				:    List[str]=True    ,     __lowerCamelCase				:    Tuple=True    ,     __lowerCamelCase				:    int=True    ,     __lowerCamelCase				:    List[str]=True    ,     __lowerCamelCase				:    Dict=9_9    ,     __lowerCamelCase				:    int=[1, 1, 2]    ,     __lowerCamelCase				:    Optional[int]=1    ,     __lowerCamelCase				:    List[Any]=3_2    ,     __lowerCamelCase				:    Union[str, Any]=4    ,     __lowerCamelCase				:    List[str]=8    ,     __lowerCamelCase				:    Optional[Any]=3_7    ,     __lowerCamelCase				:    List[str]="gelu_new"    ,     __lowerCamelCase				:    Tuple=0.1    ,     __lowerCamelCase				:    Optional[int]=0.1    ,     __lowerCamelCase				:    Optional[int]=0.0    ,     __lowerCamelCase				:    int=5_1_2    ,     __lowerCamelCase				:    int=3    ,     __lowerCamelCase				:    List[str]=0.02    ,     __lowerCamelCase				:    int=3    ,     __lowerCamelCase				:    Union[str, Any]=4    ,     __lowerCamelCase				:    List[str]=None    ,     __lowerCamelCase				:    Optional[int]=False    ,     )					->       str:
										__magic_name__      =  parent
										__magic_name__      =  batch_size
										__magic_name__      =  seq_length
										__magic_name__      =  is_training
										__magic_name__      =  use_input_mask
										__magic_name__      =  use_token_type_ids
										__magic_name__      =  use_labels
										__magic_name__      =  vocab_size
										__magic_name__      =  block_sizes
										__magic_name__      =  num_decoder_layers
										__magic_name__      =  d_model
										__magic_name__      =  n_head
										__magic_name__      =  d_head
										__magic_name__      =  d_inner
										__magic_name__      =  hidden_act
										__magic_name__      =  hidden_dropout
										__magic_name__      =  attention_dropout
										__magic_name__      =  activation_dropout
										__magic_name__      =  max_position_embeddings
										__magic_name__      =  type_vocab_size
										__magic_name__      =  2
										__magic_name__      =  num_labels
										__magic_name__      =  num_choices
										__magic_name__      =  scope
										__magic_name__      =  initializer_std

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







				def      _snake_case       (				self				:    Any						)					->       str:
										__magic_name__      =  ids_tensor([self.batch_size, self.seq_length]    ,     self.vocab_size						)

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

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

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

										__magic_name__      =  self.get_config()

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







				def      _snake_case       (				self				:    Tuple						)					->       List[str]:
										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      _snake_case       (				self				:    Tuple    ,     __lowerCamelCase				:    List[Any]    ,     __lowerCamelCase				:    Union[str, Any]    ,     __lowerCamelCase				:    List[str]    ,     __lowerCamelCase				:    Tuple    ,     __lowerCamelCase				:    Optional[Any]    ,     __lowerCamelCase				:    str    ,     __lowerCamelCase				:    Tuple    ,     __lowerCamelCase				:    Any    ,     )					->       List[str]:
										__magic_name__      =  FunnelModel(config=__lowerCamelCase						)
										model.to(__lowerCamelCase						)
										model.eval()
										__magic_name__      =  model(__lowerCamelCase    ,     attention_mask=__lowerCamelCase    ,     token_type_ids=__lowerCamelCase						)
										__magic_name__      =  model(__lowerCamelCase    ,     token_type_ids=__lowerCamelCase						)
										__magic_name__      =  model(__lowerCamelCase						)
										self.parent.assertEqual(result.last_hidden_state.shape    ,     (self.batch_size, self.seq_length, self.d_model)						)

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

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







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

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

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







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







				def      _snake_case       (				self				:    Dict    ,     __lowerCamelCase				:    Optional[Any]    ,     __lowerCamelCase				:    List[Any]    ,     __lowerCamelCase				:    Dict    ,     __lowerCamelCase				:    Any    ,     __lowerCamelCase				:    Optional[int]    ,     __lowerCamelCase				:    Optional[int]    ,     __lowerCamelCase				:    Union[str, Any]    ,     __lowerCamelCase				:    str    ,     )					->       Optional[int]:
										__magic_name__      =  FunnelForMaskedLM(config=__lowerCamelCase						)
										model.to(__lowerCamelCase						)
										model.eval()
										__magic_name__      =  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      _snake_case       (				self				:    Tuple    ,     __lowerCamelCase				:    List[Any]    ,     __lowerCamelCase				:    List[str]    ,     __lowerCamelCase				:    int    ,     __lowerCamelCase				:    str    ,     __lowerCamelCase				:    Optional[int]    ,     __lowerCamelCase				:    Optional[int]    ,     __lowerCamelCase				:    List[Any]    ,     __lowerCamelCase				:    List[Any]    ,     )					->       List[Any]:
										__magic_name__      =  self.num_labels
										__magic_name__      =  FunnelForSequenceClassification(__lowerCamelCase						)
										model.to(__lowerCamelCase						)
										model.eval()
										__magic_name__      =  model(__lowerCamelCase    ,     attention_mask=__lowerCamelCase    ,     token_type_ids=__lowerCamelCase    ,     labels=__lowerCamelCase						)
										self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, self.num_labels)						)







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







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





@require_torch
class     A_				(   snake_case_       ,				snake_case_       ,				unittest.TestCase	):
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					(
				    (
				        FunnelModel,
				        FunnelForMaskedLM,
				        FunnelForPreTraining,
				        FunnelForQuestionAnswering,
				        FunnelForTokenClassification,
				    )
				    if is_torch_available()
				    else ()
				)
				UpperCAmelCase__										=					(
				    {
				        '''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      _snake_case       (				self				:    List[Any]    ,     __lowerCamelCase				:    Union[str, Any]    ,     __lowerCamelCase				:    Union[str, Any]    ,     __lowerCamelCase				:    List[Any]=False						)					->       Union[str, Any]:
										__magic_name__      =  super()._prepare_for_class(__lowerCamelCase    ,     __lowerCamelCase    ,     return_labels=__lowerCamelCase						)

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







				def      _snake_case       (				self				:    Dict						)					->       Dict:
										__magic_name__      =  FunnelModelTester(self						)
										__magic_name__      =  ConfigTester(self    ,     config_class=__lowerCamelCase						)







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







				def      _snake_case       (				self				:    Optional[int]						)					->       Union[str, Any]:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*__lowerCamelCase						)







				def      _snake_case       (				self				:    Optional[int]						)					->       Optional[Any]:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_pretraining(*__lowerCamelCase						)







				def      _snake_case       (				self				:    List[str]						)					->       Any:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*__lowerCamelCase						)







				def      _snake_case       (				self				:    int						)					->       Union[str, Any]:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_token_classification(*__lowerCamelCase						)







				def      _snake_case       (				self				:    Any						)					->       Optional[Any]:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*__lowerCamelCase						)







				def      _snake_case       (				self				:    List[str]    ,     __lowerCamelCase				:    int						)					->       List[str]:
										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:
																						__magic_name__      =  getattr(__lowerCamelCase    ,     __lowerCamelCase						)
																						weight.data.fill_(3						)





@require_torch
class     A_				(   snake_case_       ,				unittest.TestCase	):
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					(
				    (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
				)







				def      _snake_case       (				self				:    int						)					->       Tuple:
										__magic_name__      =  FunnelModelTester(self    ,     base=__lowerCamelCase						)
										__magic_name__      =  ConfigTester(self    ,     config_class=__lowerCamelCase						)







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







				def      _snake_case       (				self				:    Dict						)					->       List[str]:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_base_model(*__lowerCamelCase						)







				def      _snake_case       (				self				:    List[str]						)					->       int:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*__lowerCamelCase						)







				def      _snake_case       (				self				:    str						)					->       Dict:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_multiple_choice(*__lowerCamelCase						)







				def      _snake_case       (				self				:    Union[str, Any]						)					->       Tuple:
										__magic_name__   ,     __magic_name__      =  self.model_tester.prepare_config_and_inputs_for_common()
										__magic_name__      =  True

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







				def      _snake_case       (				self				:    int    ,     __lowerCamelCase				:    Tuple						)					->       str:
										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:
																						__magic_name__      =  getattr(__lowerCamelCase    ,     __lowerCamelCase						)
																						weight.data.fill_(3						)





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







				def      _snake_case       (				self				:    int						)					->       int:
										__magic_name__      =  1_3
										__magic_name__      =  7
										__magic_name__      =  torch.arange(0    ,     batch_size * sequence_length						).long().reshape(__lowerCamelCase    ,     __lowerCamelCase						)
										__magic_name__      =  [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
										__magic_name__      =  torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]						)

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

										__magic_name__      =  torch.tensor(2344.8352						)
										__magic_name__      =  torch.tensor(0.8052						)
										self.assertTrue(torch.allclose(output.sum()    ,     __lowerCamelCase    ,     atol=1e-4						)						)
										self.assertTrue(torch.allclose(output.mean()    ,     __lowerCamelCase    ,     atol=1e-4						)						)

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

										__magic_name__      =  torch.tensor(2343.8425						)
										__magic_name__      =  torch.tensor(0.8049						)
										self.assertTrue(torch.allclose(output.sum()    ,     __lowerCamelCase    ,     atol=1e-4						)						)
										self.assertTrue(torch.allclose(output.mean()    ,     __lowerCamelCase    ,     atol=1e-4						)						)







				@slow
				def      _snake_case       (				self				:    Dict						)					->       Optional[int]:
										__magic_name__      =  FunnelTokenizer.from_pretrained("huggingface/funnel-small"						)
										__magic_name__      =  FunnelModel.from_pretrained("huggingface/funnel-small"						)
										__magic_name__      =  tokenizer("Hello! I am the Funnel Transformer model."    ,     return_tensors="pt"						)
										__magic_name__      =  model(**__lowerCamelCase						)[0]

										__magic_name__      =  torch.tensor(235.7246						)
										__magic_name__      =  torch.tensor(0.0256						)
										self.assertTrue(torch.allclose(output.sum()    ,     __lowerCamelCase    ,     atol=1e-4						)						)
										self.assertTrue(torch.allclose(output.mean()    ,     __lowerCamelCase    ,     atol=1e-4						)						)











"""simple docstring"""

import math






def _lowerCAmelCase						(	__lowerCamelCase:int ):

						'''simple docstring'''






						if number == 0:
												__magic_name__      =  "Zero"
												return words
						else:
												__magic_name__      =  math.logaa(__lowerCamelCase )
												__magic_name__      =  digits + 1
												__magic_name__      =  {}
												__magic_name__      =  ""
												__magic_name__      =  "One"
												__magic_name__      =  "Two"
												__magic_name__      =  "Three"
												__magic_name__      =  "Four"
												__magic_name__      =  "Five"
												__magic_name__      =  "Six"
												__magic_name__      =  "Seven"
												__magic_name__      =  "Eight"
												__magic_name__      =  "Nine"

												__magic_name__      =  {}
												__magic_name__      =  ""
												__magic_name__      =  "Twenty"
												__magic_name__      =  "Thirty"
												__magic_name__      =  "Forty"
												__magic_name__      =  "Fifty"
												__magic_name__      =  "Sixty"
												__magic_name__      =  "Seventy"
												__magic_name__      =  "Eighty"
												__magic_name__      =  "Ninety"

												__magic_name__      =  {}
												__magic_name__      =  "Ten"
												__magic_name__      =  "Eleven"
												__magic_name__      =  "Twelve"
												__magic_name__      =  "Thirteen"
												__magic_name__      =  "Fourteen"
												__magic_name__      =  "Fifteen"
												__magic_name__      =  "Sixteen"
												__magic_name__      =  "Seventeen"
												__magic_name__      =  "Eighteen"
												__magic_name__      =  "Nineteen"

												__magic_name__      =  {}
												__magic_name__      =  "Hundred,"
												__magic_name__      =  "Thousand,"
												__magic_name__      =  "Lakh,"
												__magic_name__      =  "Crore,"

												__magic_name__      =  number
												__magic_name__      =  ""
												__magic_name__      =  0
												__magic_name__      =  int(__lowerCamelCase )
												while counter < digits:
																		__magic_name__      =  temp_num % 1_0
																		if counter % 2 == 0:
																								__magic_name__      =  ""
																								if counter in placevalue and current != 0:
																														__magic_name__      =  placevalue[counter]
																								if counter == 2:
																														__magic_name__      =  singles[current] + addition + words
																								elif counter == 0:
																														if ((temp_num % 1_0_0) // 1_0) == 1:
																																				__magic_name__      =  teens[current] + addition + words
																																				__magic_name__      =  temp_num // 1_0
																																				counter += 1
																														else:
																																				__magic_name__      =  singles[current] + addition + words

																								else:
																														__magic_name__      =  doubles[current] + addition + words

																		else:
																								if counter == 1:
																														if current == 1:
																																				__magic_name__      =  teens[number % 1_0] + words
																														else:
																																				__magic_name__      =  ""
																																				if counter in placevalue:
																																										__magic_name__      =  placevalue[counter]
																																				__magic_name__      =  doubles[current] + addition + words
																								else:
																														__magic_name__      =  ""
																														if counter in placevalue:
																																				if current == 0 and ((temp_num % 1_0_0) // 1_0) == 0:
																																										__magic_name__      =  ""
																																				else:
																																										__magic_name__      =  placevalue[counter]
																														if ((temp_num % 1_0_0) // 1_0) == 1:
																																				__magic_name__      =  teens[current] + addition + words
																																				__magic_name__      =  temp_num // 1_0
																																				counter += 1
																														else:
																																				__magic_name__      =  singles[current] + addition + words
																		counter += 1
																		__magic_name__      =  temp_num // 1_0
						return words


if __name__ == "__main__":
			import doctest

			doctest.testmod()



