






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

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







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Tuple   =   ids_tensor([self.batch_size, self.seq_length]							,       self.vocab_size  )

								__magic_name__		:Optional[Any]   =   None
								if self.use_input_mask:
												__magic_name__		:Dict   =   random_attention_mask([self.batch_size, self.seq_length]  )

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

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

								__magic_name__		:Optional[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       A						(    self							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       ):
								"""simple docstring"""
								__magic_name__		:List[Any]   =   TFFunnelModel(config=__lowerCAmelCase  )
								__magic_name__		:Optional[int]   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:str   =   model(__lowerCAmelCase  )

								__magic_name__		:Any   =   [input_ids, input_mask]
								__magic_name__		:Any   =   model(__lowerCAmelCase  )

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

								__magic_name__		:List[str]   =   False
								__magic_name__		:int   =   TFFunnelModel(config=__lowerCAmelCase  )
								__magic_name__		:Optional[Any]   =   model(__lowerCAmelCase  )
								self.parent.assertEqual(result.last_hidden_state.shape							,       (self.batch_size, self.seq_length, self.d_model)  )

								__magic_name__		:Optional[Any]   =   False
								__magic_name__		:List[Any]   =   TFFunnelModel(config=__lowerCAmelCase  )
								__magic_name__		:Optional[int]   =   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							,       ):
								"""simple docstring"""
								__magic_name__		:Any   =   TFFunnelBaseModel(config=__lowerCAmelCase  )
								__magic_name__		:Union[str, Any]   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:int   =   model(__lowerCAmelCase  )

								__magic_name__		:str   =   [input_ids, input_mask]
								__magic_name__		:Optional[Any]   =   model(__lowerCAmelCase  )

								__magic_name__		:List[Any]   =   model(__lowerCAmelCase  )
								self.parent.assertEqual(result.last_hidden_state.shape							,       (self.batch_size, 2, self.d_model)  )

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

								__magic_name__		:Union[str, Any]   =   False
								__magic_name__		:Union[str, Any]   =   TFFunnelBaseModel(config=__lowerCAmelCase  )
								__magic_name__		:Dict   =   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							,       ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]   =   TFFunnelForPreTraining(config=__lowerCAmelCase  )
								__magic_name__		:str   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:List[Any]   =   model(__lowerCAmelCase  )
								self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.seq_length)  )







				def       A						(    self							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       ):
								"""simple docstring"""
								__magic_name__		:int   =   TFFunnelForMaskedLM(config=__lowerCAmelCase  )
								__magic_name__		:Optional[int]   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:List[Any]   =   model(__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							,       ):
								"""simple docstring"""
								__magic_name__		:int   =   self.num_labels
								__magic_name__		:List[Any]   =   TFFunnelForSequenceClassification(config=__lowerCAmelCase  )
								__magic_name__		:List[Any]   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:Optional[int]   =   model(__lowerCAmelCase  )
								self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.num_labels)  )







				def       A						(    self							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       ):
								"""simple docstring"""
								__magic_name__		:str   =   self.num_choices
								__magic_name__		:Union[str, Any]   =   TFFunnelForMultipleChoice(config=__lowerCAmelCase  )
								__magic_name__		:List[str]   =   tf.tile(tf.expand_dims(__lowerCAmelCase							,       1  )							,       (1, self.num_choices, 1)  )
								__magic_name__		:Union[str, Any]   =   tf.tile(tf.expand_dims(__lowerCAmelCase							,       1  )							,       (1, self.num_choices, 1)  )
								__magic_name__		:Any   =   tf.tile(tf.expand_dims(__lowerCAmelCase							,       1  )							,       (1, self.num_choices, 1)  )
								__magic_name__		:str   =   {
								    '''input_ids''': multiple_choice_inputs_ids,
								    '''attention_mask''': multiple_choice_input_mask,
								    '''token_type_ids''': multiple_choice_token_type_ids,
								}
								__magic_name__		:Tuple   =   model(__lowerCAmelCase  )
								self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.num_choices)  )







				def       A						(    self							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase							,       ):
								"""simple docstring"""
								__magic_name__		:List[str]   =   self.num_labels
								__magic_name__		:Union[str, Any]   =   TFFunnelForTokenClassification(config=__lowerCAmelCase  )
								__magic_name__		:Dict   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:int   =   model(__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							,       ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]   =   TFFunnelForQuestionAnswering(config=__lowerCAmelCase  )
								__magic_name__		:Optional[Any]   =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								__magic_name__		:Union[str, Any]   =   model(__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  ):
								"""simple docstring"""
								__magic_name__		:Tuple   =   self.prepare_config_and_inputs()
								(
								    (
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					(
								    __magic_name__
								)  ,					
								)		:Union[str, Any]   =   config_and_inputs
								__magic_name__		:int   =   {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
								return config, inputs_dict







@require_tf
class     lowerCamelCase_					(   lowerCamelCase      ,					lowerCamelCase      ,					unittest.TestCase			):
				a__       							=	(
				    (
				        TFFunnelModel,
				        TFFunnelForMaskedLM,
				        TFFunnelForPreTraining,
				        TFFunnelForQuestionAnswering,
				        TFFunnelForTokenClassification,
				    )
				    if is_tf_available()
				    else ()
				)
				a__       							=	(
				    {
				        '''feature-extraction''': (TFFunnelBaseModel, TFFunnelModel),
				        '''fill-mask''': TFFunnelForMaskedLM,
				        '''question-answering''': TFFunnelForQuestionAnswering,
				        '''text-classification''': TFFunnelForSequenceClassification,
				        '''token-classification''': TFFunnelForTokenClassification,
				        '''zero-shot''': TFFunnelForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)
				a__       							=	False
				a__       							=	False







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   TFFunnelModelTester(self  )
								__magic_name__		:Optional[int]   =   ConfigTester(self							,       config_class=__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								self.config_tester.run_common_tests()







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Any   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_pretraining(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:str   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_lm(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*__lowerCAmelCase  )







@require_tf
class     lowerCamelCase_					(   lowerCamelCase      ,					unittest.TestCase			):
				a__       							=	(
				    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
				)
				a__       							=	False
				a__       							=	False







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]   =   TFFunnelModelTester(self							,       base=__lowerCAmelCase  )
								__magic_name__		:Union[str, Any]   =   ConfigTester(self							,       config_class=__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								self.config_tester.run_common_tests()







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[str]   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_base_model(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Any   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*__lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[Any]   =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_multiple_choice(*__lowerCAmelCase  )














import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
					import jax.numpy as jnp

if is_tf_available():
					import tensorflow as tf

if is_torch_available():
					import torch
class     lowerCamelCase_					(   unittest.TestCase			):







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[Any]   =   {
								    '''task_specific_params''': {
								        '''summarization''': {'''length_penalty''': 1.0, '''max_length''': 1_2_8, '''min_length''': 1_2, '''num_beams''': 4},
								        '''summarization_cnn''': {'''length_penalty''': 2.0, '''max_length''': 1_4_2, '''min_length''': 5_6, '''num_beams''': 4},
								        '''summarization_xsum''': {'''length_penalty''': 1.0, '''max_length''': 6_2, '''min_length''': 1_1, '''num_beams''': 6},
								    }
								}
								__magic_name__		:List[str]   =   {
								    '''task_specific_params.summarization.length_penalty''': 1.0,
								    '''task_specific_params.summarization.max_length''': 1_2_8,
								    '''task_specific_params.summarization.min_length''': 1_2,
								    '''task_specific_params.summarization.num_beams''': 4,
								    '''task_specific_params.summarization_cnn.length_penalty''': 2.0,
								    '''task_specific_params.summarization_cnn.max_length''': 1_4_2,
								    '''task_specific_params.summarization_cnn.min_length''': 5_6,
								    '''task_specific_params.summarization_cnn.num_beams''': 4,
								    '''task_specific_params.summarization_xsum.length_penalty''': 1.0,
								    '''task_specific_params.summarization_xsum.max_length''': 6_2,
								    '''task_specific_params.summarization_xsum.min_length''': 1_1,
								    '''task_specific_params.summarization_xsum.num_beams''': 6,
								}

								self.assertEqual(flatten_dict(__lowerCAmelCase  )							,       __lowerCAmelCase  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Optional[Any]   =   np.random.randn(3							,       4  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase  )							,       x.transpose()  )  )

								__magic_name__		:List[Any]   =   np.random.randn(3							,       4							,       5  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  )							,       x.transpose((1, 2, 0)  )  )  )







				@require_torch
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Optional[Any]   =   np.random.randn(3							,       4  )
								__magic_name__		:Tuple   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase  )							,       transpose(__lowerCAmelCase  ).numpy()  )  )

								__magic_name__		:int   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:Union[str, Any]   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  )							,       transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  ).numpy()  )  )







				@require_tf
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:int   =   np.random.randn(3							,       4  )
								__magic_name__		:Optional[Any]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase  )							,       transpose(__lowerCAmelCase  ).numpy()  )  )

								__magic_name__		:List[str]   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:Optional[Any]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  )							,       transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  ).numpy()  )  )







				@require_flax
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:int   =   np.random.randn(3							,       4  )
								__magic_name__		:Dict   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase  )							,       np.asarray(transpose(__lowerCAmelCase  )  )  )  )

								__magic_name__		:Dict   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:Dict   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  )							,       np.asarray(transpose(__lowerCAmelCase							,       axes=(1, 2, 0)  )  )  )  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Any   =   np.random.randn(3							,       4  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (4, 3)  )							,       np.reshape(__lowerCAmelCase							,       (4, 3)  )  )  )

								__magic_name__		:Union[str, Any]   =   np.random.randn(3							,       4							,       5  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (1_2, 5)  )							,       np.reshape(__lowerCAmelCase							,       (1_2, 5)  )  )  )







				@require_torch
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   np.random.randn(3							,       4  )
								__magic_name__		:Tuple   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (4, 3)  )							,       reshape(__lowerCAmelCase							,       (4, 3)  ).numpy()  )  )

								__magic_name__		:Union[str, Any]   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:List[str]   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (1_2, 5)  )							,       reshape(__lowerCAmelCase							,       (1_2, 5)  ).numpy()  )  )







				@require_tf
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   np.random.randn(3							,       4  )
								__magic_name__		:Union[str, Any]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (4, 3)  )							,       reshape(__lowerCAmelCase							,       (4, 3)  ).numpy()  )  )

								__magic_name__		:List[Any]   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:Optional[int]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (1_2, 5)  )							,       reshape(__lowerCAmelCase							,       (1_2, 5)  ).numpy()  )  )







				@require_flax
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[str]   =   np.random.randn(3							,       4  )
								__magic_name__		:Any   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (4, 3)  )							,       np.asarray(reshape(__lowerCAmelCase							,       (4, 3)  )  )  )  )

								__magic_name__		:List[Any]   =   np.random.randn(3							,       4							,       5  )
								__magic_name__		:List[str]   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,       (1_2, 5)  )							,       np.asarray(reshape(__lowerCAmelCase							,       (1_2, 5)  )  )  )  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[Any]   =   np.random.randn(1							,       3							,       4  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase  )							,       np.squeeze(__lowerCAmelCase  )  )  )

								__magic_name__		:Optional[Any]   =   np.random.randn(1							,       4							,       1							,       5  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,       axis=2  )							,       np.squeeze(__lowerCAmelCase							,       axis=2  )  )  )







				@require_torch
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Dict   =   np.random.randn(1							,       3							,       4  )
								__magic_name__		:List[Any]   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase  )							,       squeeze(__lowerCAmelCase  ).numpy()  )  )

								__magic_name__		:List[str]   =   np.random.randn(1							,       4							,       1							,       5  )
								__magic_name__		:str   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,       axis=2  )							,       squeeze(__lowerCAmelCase							,       axis=2  ).numpy()  )  )







				@require_tf
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:int   =   np.random.randn(1							,       3							,       4  )
								__magic_name__		:Tuple   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase  )							,       squeeze(__lowerCAmelCase  ).numpy()  )  )

								__magic_name__		:Tuple   =   np.random.randn(1							,       4							,       1							,       5  )
								__magic_name__		:Optional[int]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,       axis=2  )							,       squeeze(__lowerCAmelCase							,       axis=2  ).numpy()  )  )







				@require_flax
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Tuple   =   np.random.randn(1							,       3							,       4  )
								__magic_name__		:Optional[Any]   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase  )							,       np.asarray(squeeze(__lowerCAmelCase  )  )  )  )

								__magic_name__		:List[Any]   =   np.random.randn(1							,       4							,       1							,       5  )
								__magic_name__		:Optional[Any]   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,       axis=2  )							,       np.asarray(squeeze(__lowerCAmelCase							,       axis=2  )  )  )  )







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Any   =   np.random.randn(3							,       4  )
								self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,       axis=1  )							,       np.expand_dims(__lowerCAmelCase							,       axis=1  )  )  )







				@require_torch
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[Any]   =   np.random.randn(3							,       4  )
								__magic_name__		:Any   =   torch.tensor(__lowerCAmelCase  )
								self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,       axis=1  )							,       expand_dims(__lowerCAmelCase							,       axis=1  ).numpy()  )  )







				@require_tf
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]   =   np.random.randn(3							,       4  )
								__magic_name__		:Union[str, Any]   =   tf.constant(__lowerCAmelCase  )
								self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,       axis=1  )							,       expand_dims(__lowerCAmelCase							,       axis=1  ).numpy()  )  )







				@require_flax
				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__		:List[str]   =   np.random.randn(3							,       4  )
								__magic_name__		:Tuple   =   jnp.array(__lowerCAmelCase  )
								self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,       axis=1  )							,       np.asarray(expand_dims(__lowerCAmelCase							,       axis=1  )  )  )  )






