





from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import (
      TFFunnelBaseModel,
      TFFunnelForMaskedLM,
      TFFunnelForMultipleChoice,
      TFFunnelForPreTraining,
      TFFunnelForQuestionAnswering,
      TFFunnelForSequenceClassification,
      TFFunnelForTokenClassification,
      TFFunnelModel,
  )







class 	__lowerCAmelCase      :





   def __init__(			self       ,      snake_case       ,      snake_case=13       ,      snake_case=7       ,      snake_case=True       ,      snake_case=True       ,      snake_case=True       ,      snake_case=True       ,      snake_case=99       ,      snake_case=[1, 1, 2]       ,      snake_case=1       ,      snake_case=32       ,      snake_case=4       ,      snake_case=8       ,      snake_case=37       ,      snake_case="gelu_new"       ,      snake_case=0.1       ,      snake_case=0.1       ,      snake_case=0.0       ,      snake_case=512       ,      snake_case=3       ,      snake_case=0.02       ,      snake_case=3       ,      snake_case=4       ,      snake_case=None       ,      snake_case=False       ,      )					->	Tuple:
      """simple docstring"""





      a__						:    int   		=	parent
      a__						:    str   		=	batch_size
      a__						:    Tuple   		=	seq_length
      a__						:    Tuple   		=	is_training
      a__						:    int   		=	use_input_mask
      a__						:    Optional[int]   		=	use_token_type_ids
      a__						:    Any   		=	use_labels
      a__						:    Union[str, Any]   		=	vocab_size
      a__						:    Optional[Any]   		=	block_sizes
      a__						:    int   		=	num_decoder_layers
      a__						:    Any   		=	d_model
      a__						:    Union[str, Any]   		=	n_head
      a__						:    List[Any]   		=	d_head
      a__						:    Dict   		=	d_inner
      a__						:    Dict   		=	hidden_act
      a__						:    Union[str, Any]   		=	hidden_dropout
      a__						:    Tuple   		=	attention_dropout
      a__						:    Union[str, Any]   		=	activation_dropout
      a__						:    Optional[Any]   		=	max_position_embeddings
      a__						:    Optional[int]   		=	type_vocab_size
      a__						:    List[Any]   		=	2
      a__						:    Optional[Any]   		=	num_labels
      a__						:    Any   		=	num_choices
      a__						:    List[Any]   		=	scope
      a__						:    Tuple   		=	initializer_std

      # Used in the tests to check the size of the first attention layer
      a__						:    Union[str, Any]   		=	n_head
      # Used in the tests to check the size of the first hidden state
      a__						:    str   		=	self.d_model
      # Used in the tests to check the number of output hidden states/attentions
      a__						:    Optional[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:
         a__						:    int   		=	self.num_hidden_layers + 2





   def 						_snake_case			(			self   )					->	Tuple:
      """simple docstring"""





      a__						:    Any   		=	ids_tensor([self.batch_size, self.seq_length]       ,      self.vocab_size   )

      a__						:    int   		=	None
      if self.use_input_mask:
         a__						:    int   		=	random_attention_mask([self.batch_size, self.seq_length]   )

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

      a__						:    Dict   		=	None
      a__						:    Dict   		=	None
      a__						:    int   		=	None
      if self.use_labels:
         a__						:    List[Any]   		=	ids_tensor([self.batch_size]       ,      self.type_sequence_label_size   )
         a__						:    List[Any]   		=	ids_tensor([self.batch_size, self.seq_length]       ,      self.num_labels   )
         a__						:    List[str]   		=	ids_tensor([self.batch_size]       ,      self.num_choices   )

      a__						:    Union[str, Any]   		=	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       ,      )

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





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	List[str]:
      """simple docstring"""





      a__						:    Any   		=	TFFunnelModel(config=snake_case   )
      a__						:    List[str]   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    Union[str, Any]   		=	model(snake_case   )

      a__						:    Tuple   		=	[input_ids, input_mask]
      a__						:    Tuple   		=	model(snake_case   )

      a__						:    str   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, self.seq_length, self.d_model)   )

      a__						:    Tuple   		=	False
      a__						:    List[str]   		=	TFFunnelModel(config=snake_case   )
      a__						:    str   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, self.seq_length, self.d_model)   )

      a__						:    Any   		=	False
      a__						:    Tuple   		=	TFFunnelModel(config=snake_case   )
      a__						:    List[Any]   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, self.seq_length, self.d_model)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	int:
      """simple docstring"""





      a__						:    Dict   		=	TFFunnelBaseModel(config=snake_case   )
      a__						:    Union[str, Any]   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    int   		=	model(snake_case   )

      a__						:    Tuple   		=	[input_ids, input_mask]
      a__						:    List[str]   		=	model(snake_case   )

      a__						:    str   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, 2, self.d_model)   )

      a__						:    Tuple   		=	False
      a__						:    List[Any]   		=	TFFunnelBaseModel(config=snake_case   )
      a__						:    str   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, 3, self.d_model)   )

      a__						:    Union[str, Any]   		=	False
      a__						:    List[str]   		=	TFFunnelBaseModel(config=snake_case   )
      a__						:    List[str]   		=	model(snake_case   )
      self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, 2, self.d_model)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	Optional[Any]:
      """simple docstring"""





      a__						:    Tuple   		=	TFFunnelForPreTraining(config=snake_case   )
      a__						:    int   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    Tuple   		=	model(snake_case   )
      self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.seq_length)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	List[Any]:
      """simple docstring"""





      a__						:    Any   		=	TFFunnelForMaskedLM(config=snake_case   )
      a__						:    Optional[Any]   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    List[str]   		=	model(snake_case   )
      self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.seq_length, self.vocab_size)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	List[str]:
      """simple docstring"""





      a__						:    Optional[Any]   		=	self.num_labels
      a__						:    List[Any]   		=	TFFunnelForSequenceClassification(config=snake_case   )
      a__						:    Tuple   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    Dict   		=	model(snake_case   )
      self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.num_labels)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	Union[str, Any]:
      """simple docstring"""





      a__						:    List[Any]   		=	self.num_choices
      a__						:    Union[str, Any]   		=	TFFunnelForMultipleChoice(config=snake_case   )
      a__						:    int   		=	tf.tile(tf.expand_dims(snake_case       ,      1   )       ,      (1, self.num_choices, 1)   )
      a__						:    str   		=	tf.tile(tf.expand_dims(snake_case       ,      1   )       ,      (1, self.num_choices, 1)   )
      a__						:    Dict   		=	tf.tile(tf.expand_dims(snake_case       ,      1   )       ,      (1, self.num_choices, 1)   )
      a__						:    List[Any]   		=	{
          "input_ids": multiple_choice_inputs_ids,
          "attention_mask": multiple_choice_input_mask,
          "token_type_ids": multiple_choice_token_type_ids,
      }
      a__						:    Dict   		=	model(snake_case   )
      self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.num_choices)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	Tuple:
      """simple docstring"""





      a__						:    List[str]   		=	self.num_labels
      a__						:    int   		=	TFFunnelForTokenClassification(config=snake_case   )
      a__						:    Any   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    Any   		=	model(snake_case   )
      self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.seq_length, self.num_labels)   )





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      )					->	List[Any]:
      """simple docstring"""





      a__						:    Optional[Any]   		=	TFFunnelForQuestionAnswering(config=snake_case   )
      a__						:    Union[str, Any]   		=	{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
      a__						:    Any   		=	model(snake_case   )
      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   )					->	int:
      """simple docstring"""





      a__						:    Optional[Any]   		=	self.prepare_config_and_inputs()
      (
          (
          a__
      )		,  (
          a__
      )		,  (
          a__
      )		,  (
          a__
      )		,  (
          a__
      )		,  (
          a__
      )		,  (
          a__
      )		,  
      )						:    Union[str, Any]   		=	config_and_inputs
      a__						:    Any   		=	{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
      return config, inputs_dict







@require_tf
class 	__lowerCAmelCase      (       _UpperCamelCase		,_UpperCamelCase		,unittest.TestCase	):
   _UpperCamelCase			:    Optional[Any]  		=					(
       (
           TFFunnelModel,
           TFFunnelForMaskedLM,
           TFFunnelForPreTraining,
           TFFunnelForQuestionAnswering,
           TFFunnelForTokenClassification,
       )
       if is_tf_available()
       else ()
   )
   _UpperCamelCase			:    Any  		=					(
       {
           """feature-extraction""": (TFFunnelBaseModel, TFFunnelModel),
           """fill-mask""": TFFunnelForMaskedLM,
           """question-answering""": TFFunnelForQuestionAnswering,
           """text-classification""": TFFunnelForSequenceClassification,
           """token-classification""": TFFunnelForTokenClassification,
           """zero-shot""": TFFunnelForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   _UpperCamelCase			:    Union[str, Any]  		=					False
   _UpperCamelCase			:    str  		=					False





   def 						_snake_case			(			self   )					->	Optional[int]:
      """simple docstring"""





      a__						:    str   		=	TFFunnelModelTester(self   )
      a__						:    Any   		=	ConfigTester(self       ,      config_class=snake_case   )





   def 						_snake_case			(			self   )					->	List[Any]:
      """simple docstring"""





      self.config_tester.run_common_tests()





   def 						_snake_case			(			self   )					->	int:
      """simple docstring"""





      a__						:    str   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[int]:
      """simple docstring"""





      a__						:    Any   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_pretraining(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[Any]:
      """simple docstring"""





      a__						:    Dict   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_masked_lm(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[Any]:
      """simple docstring"""





      a__						:    Any   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[int]:
      """simple docstring"""





      a__						:    Any   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*snake_case   )







@require_tf
class 	__lowerCAmelCase      (       _UpperCamelCase		,unittest.TestCase	):
   _UpperCamelCase			:    List[Any]  		=					(
       (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
   )
   _UpperCamelCase			:    List[str]  		=					False
   _UpperCamelCase			:    List[Any]  		=					False





   def 						_snake_case			(			self   )					->	List[str]:
      """simple docstring"""





      a__						:    str   		=	TFFunnelModelTester(self       ,      base=snake_case   )
      a__						:    List[str]   		=	ConfigTester(self       ,      config_class=snake_case   )





   def 						_snake_case			(			self   )					->	Tuple:
      """simple docstring"""





      self.config_tester.run_common_tests()





   def 						_snake_case			(			self   )					->	Any:
      """simple docstring"""





      a__						:    Tuple   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_base_model(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[int]:
      """simple docstring"""





      a__						:    int   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*snake_case   )





   def 						_snake_case			(			self   )					->	Optional[int]:
      """simple docstring"""





      a__						:    List[str]   		=	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*snake_case   )








# Function to print upper half of diamond (pyramid)






def    _A	(   lowerCamelCase ):
   for i in range(0				,			lowerCamelCase ):
      for _ in range(0				,			n - i - 1 ):  # printing spaces
         print(" "				,			end="" )
      for _ in range(0				,			i + 1 ):  # printing stars
         print("* "				,			end="" )
      print()






def    _A	(   lowerCamelCase ):
   for i in range(lowerCamelCase				,			0				,			-1 ):
      for _ in range(lowerCamelCase				,			0				,			-1 ):  # printing stars
         print("* "				,			end="" )
      print()
      for _ in range(n - i + 1				,			0				,			-1 ):  # printing spaces
         print(" "				,			end="" )






def    _A	(   lowerCamelCase ):
   if n <= 0:
      print("       ...       ....        nothing printing :(" )
      return
   floyd(lowerCamelCase )  # upper half
   reverse_floyd(lowerCamelCase )  # lower half


if __name__ == "__main__":
  print(R"""| /\ | |- |  |-  |--| |\  /| |-""")
  print(R"""|/  \| |- |_ |_  |__| | \/ | |_""")
  SCREAMING_SNAKE_CASE__							:      Dict         =    1
  while K:
    SCREAMING_SNAKE_CASE__							:      str         =    int(input("""enter the number and , and see the magic : """))
    print()
    pretty_print(user_number)
    SCREAMING_SNAKE_CASE__							:      Tuple         =    int(input("""press 0 to exit... and 1 to continue..."""))

  print("""Good Bye...""")

