import inspect
import unittest

from transformers import DPTConfig
from transformers.file_utils import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch
		from torch import nn

		from transformers import MODEL_MAPPING, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTModel
		from transformers.models.dpt.modeling_dpt import DPT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
		from PIL import Image

		from transformers import DPTImageProcessor






class 		a__						:

					def __init__(    self      :       str,_A      :       str,_A      :       str=2,_A      :       List[str]=32,_A      :       List[Any]=16,_A      :       Any=3,_A      :       str=True,_A      :       Union[str, Any]=True,_A      :       Union[str, Any]=32,_A      :       Optional[Any]=4,_A      :       Any=[0, 1, 2, 3],_A      :       Any=4,_A      :       Tuple=37,_A      :       List[str]="gelu",_A      :       Optional[int]=0.1,_A      :       str=0.1,_A      :       int=0.02,_A      :       Optional[int]=3,_A      :       str=[1, 384, 24, 24],_A      :       str=True,_A      :       Tuple=None,):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Dict				      =    parent
							SCREAMING_SNAKE_CASE_  :		Any				      =    batch_size
							SCREAMING_SNAKE_CASE_  :		Any				      =    image_size
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    patch_size
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    num_channels
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    is_training
							SCREAMING_SNAKE_CASE_  :		Any				      =    use_labels
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    hidden_size
							SCREAMING_SNAKE_CASE_  :		Any				      =    num_hidden_layers
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    backbone_out_indices
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    num_attention_heads
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    intermediate_size
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    hidden_act
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    hidden_dropout_prob
							SCREAMING_SNAKE_CASE_  :		int				      =    attention_probs_dropout_prob
							SCREAMING_SNAKE_CASE_  :		Dict				      =    initializer_range
							SCREAMING_SNAKE_CASE_  :		int				      =    num_labels
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    backbone_featmap_shape
							SCREAMING_SNAKE_CASE_  :		str				      =    scope
							SCREAMING_SNAKE_CASE_  :		Any				      =    is_hybrid
							# sequence length of DPT = num_patches + 1 (we add 1 for the [CLS] token)
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    (image_size // patch_size) ** 2
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    num_patches + 1

					def 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Dict				      =    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

							SCREAMING_SNAKE_CASE_  :		Dict				      =    None
							if self.use_labels:
									SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    ids_tensor([self.batch_size, self.image_size, self.image_size],self.num_labels    )

							SCREAMING_SNAKE_CASE_  :		str				      =    self.get_config()

							return config, pixel_values, labels

					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    {
							    "global_padding": "same",
							    "layer_type": "bottleneck",
							    "depths": [3, 4, 9],
							    "out_features": ["stage1", "stage2", "stage3"],
							    "embedding_dynamic_padding": True,
							    "hidden_sizes": [96, 192, 384, 768],
							    "num_groups": 2,
							}

							return DPTConfig(
							    image_size=self.image_size,patch_size=self.patch_size,num_channels=self.num_channels,hidden_size=self.hidden_size,num_hidden_layers=self.num_hidden_layers,backbone_out_indices=self.backbone_out_indices,num_attention_heads=self.num_attention_heads,intermediate_size=self.intermediate_size,hidden_act=self.hidden_act,hidden_dropout_prob=self.hidden_dropout_prob,attention_probs_dropout_prob=self.attention_probs_dropout_prob,is_decoder=_A,initializer_range=self.initializer_range,is_hybrid=self.is_hybrid,backbone_config=_A,backbone_featmap_shape=self.backbone_featmap_shape,)

					def 				__UpperCamelCase   (    self      :       Union[str, Any],_A      :       Optional[int],_A      :       Union[str, Any],_A      :       Tuple    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    DPTModel(config=_A    )
							model.to(_A    )
							model.eval()
							SCREAMING_SNAKE_CASE_  :		Any				      =    model(_A    )
							self.parent.assertEqual(result.last_hidden_state.shape,(self.batch_size, self.seq_length, self.hidden_size)    )

					def 				__UpperCamelCase   (    self      :       Dict,_A      :       List[Any],_A      :       str,_A      :       int    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		int				      =    self.num_labels
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    DPTForDepthEstimation(_A    )
							model.to(_A    )
							model.eval()
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    model(_A    )
							self.parent.assertEqual(result.predicted_depth.shape,(self.batch_size, self.image_size, self.image_size)    )

					def 				__UpperCamelCase   (    self      :       List[str],_A      :       Tuple,_A      :       Tuple,_A      :       str    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    self.num_labels
							SCREAMING_SNAKE_CASE_  :		Dict				      =    DPTForSemanticSegmentation(_A    )
							model.to(_A    )
							model.eval()
							SCREAMING_SNAKE_CASE_  :		Any				      =    model(_A,labels=_A    )
							self.parent.assertEqual(
							    result.logits.shape,(self.batch_size, self.num_labels, self.image_size, self.image_size)    )






					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    self.prepare_config_and_inputs()
							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		str				      =    config_and_inputs
							SCREAMING_SNAKE_CASE_  :		int				      =    {"pixel_values": pixel_values}
							return config, inputs_dict







@require_torch
class 		a__						(					A__    ,		A__    ,		unittest.TestCase					):
					A	       =							(DPTModel, DPTForDepthEstimation, DPTForSemanticSegmentation) if is_torch_available() else ()
					A	       =							(
					    {
					        'depth-estimation': DPTForDepthEstimation,
					        'feature-extraction': DPTModel,
					        'image-segmentation': DPTForSemanticSegmentation,
					    }
					    if is_torch_available()
					    else {}
					)

					A	       =							False
					A	       =							False
					A	       =							False

					def 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    DPTModelTester(self    )
							SCREAMING_SNAKE_CASE_  :		int				      =    ConfigTester(self,config_class=_A,has_text_modality=_A,hidden_size=37    )

					def 				__UpperCamelCase   (    self      :       str    ):







							"""simple docstring"""






							self.config_tester.run_common_tests()

					@unittest.skip(reason="DPT does not use inputs_embeds"    )
					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							pass

					def 				__UpperCamelCase   (    self      :       str    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		Dict				      =    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    model_class(_A    )
									self.assertIsInstance(model.get_input_embeddings(),(nn.Module)    )
									SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    model.get_output_embeddings()
									self.assertTrue(x is None or isinstance(_A,nn.Linear    )    )

					def 				__UpperCamelCase   (    self      :       int    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		Any				      =    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE_  :		List[str]				      =    model_class(_A    )
									SCREAMING_SNAKE_CASE_  :		Dict				      =    inspect.signature(model.forward    )
									# signature.parameters is an OrderedDict => so arg_names order is deterministic
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    [*signature.parameters.keys()]

									SCREAMING_SNAKE_CASE_  :		Dict				      =    ["pixel_values"]
									self.assertListEqual(arg_names[:1],_A    )

					def 				__UpperCamelCase   (    self      :       Tuple    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*_A    )

					def 				__UpperCamelCase   (    self      :       Any    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_depth_estimation(*_A    )

					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_semantic_segmentation(*_A    )

					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							for model_class in self.all_model_classes:
									if model_class.__name__ == "DPTForDepthEstimation":
											continue

									SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		List[Any]				      =    self.model_tester.prepare_config_and_inputs_for_common()
									SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    True

									if model_class in get_values(_A    ):
											continue

									SCREAMING_SNAKE_CASE_  :		List[Any]				      =    model_class(_A    )
									model.to(_A    )
									model.train()
									SCREAMING_SNAKE_CASE_  :		List[Any]				      =    self._prepare_for_class(_A,_A,return_labels=_A    )
									SCREAMING_SNAKE_CASE_  :		Dict				      =    model(**_A    ).loss
									loss.backward()

					def 				__UpperCamelCase   (    self      :       Any    ):







							"""simple docstring"""






							for model_class in self.all_model_classes:
									if model_class.__name__ == "DPTForDepthEstimation":
											continue

									SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		Dict				      =    self.model_tester.prepare_config_and_inputs_for_common()
									SCREAMING_SNAKE_CASE_  :		List[str]				      =    False
									SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    True

									if model_class in get_values(_A    ) or not model_class.supports_gradient_checkpointing:
											continue
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    model_class(_A    )
									model.to(_A    )
									model.gradient_checkpointing_enable()
									model.train()
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    self._prepare_for_class(_A,_A,return_labels=_A    )
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    model(**_A    ).loss
									loss.backward()

					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    self.model_tester.prepare_config_and_inputs_for_common()

							SCREAMING_SNAKE_CASE_  :		Any				      =    _config_zero_init(_A    )
							for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE_  :		List[str]				      =    model_class(config=_A    )
									# Skip the check for the backbone
									SCREAMING_SNAKE_CASE_  :		Any				      =    []
									for name, module in model.named_modules():
											if module.__class__.__name__ == "DPTViTHybridEmbeddings":
													SCREAMING_SNAKE_CASE_  :		List[str]				      =    [F'{name}.{key}' for key in module.state_dict().keys()]
													break

									for name, param in model.named_parameters():
											if param.requires_grad:
													if name in backbone_params:
															continue
													self.assertIn(
													    ((param.data.mean() * 1E9).round() / 1E9).item(),[0.0, 1.0],msg=F'Parameter {name} of model {model_class} seems not properly initialized',)

					@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."    )
					def 				__UpperCamelCase   (    self      :       List[Any]    ):







							"""simple docstring"""






							pass

					@slow
					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							for model_name in DPT_PRETRAINED_MODEL_ARCHIVE_LIST[1:]:
									SCREAMING_SNAKE_CASE_  :		Any				      =    DPTModel.from_pretrained(_A    )
									self.assertIsNotNone(_A    )






					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_  :		int				      =    self.model_tester.prepare_config_and_inputs_for_common()
							SCREAMING_SNAKE_CASE_  :		Dict				      =    "add"
							with self.assertRaises(_A    ):
									SCREAMING_SNAKE_CASE_  :		Any				      =    DPTForDepthEstimation(_A    )







def       _snake_case	(   ):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"	)
		return image







@require_torch
@require_vision
@slow
class 		a__						(					unittest.TestCase					):

					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Any				      =    DPTImageProcessor.from_pretrained("Intel/dpt-hybrid-midas"    )
							SCREAMING_SNAKE_CASE_  :		Dict				      =    DPTForDepthEstimation.from_pretrained("Intel/dpt-hybrid-midas"    ).to(_A    )

							SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    prepare_img()
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    image_processor(images=_A,return_tensors="pt"    ).to(_A    )

							# forward pass
							with torch.no_grad():
									SCREAMING_SNAKE_CASE_  :		List[Any]				      =    model(**_A    )
									SCREAMING_SNAKE_CASE_  :		Tuple				      =    outputs.predicted_depth

							# verify the predicted depth
							SCREAMING_SNAKE_CASE_  :		int				      =    torch.Size((1, 384, 384)    )
							self.assertEqual(predicted_depth.shape,_A    )

							SCREAMING_SNAKE_CASE_  :		Any				      =    torch.tensor(
							    [[[5.6437, 5.6146, 5.6511], [5.4371, 5.5649, 5.5958], [5.5215, 5.5184, 5.5293]]]    ).to(_A    )

							self.assertTrue(torch.allclose(outputs.predicted_depth[:3, :3, :3] / 100,_A,atol=1E-4    )    )

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 		a__						(					unittest.TestCase					):

					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Dict				      =    {
							    "task_specific_params": {
							        "summarization": {"length_penalty": 1.0, "max_length": 128, "min_length": 12, "num_beams": 4},
							        "summarization_cnn": {"length_penalty": 2.0, "max_length": 142, "min_length": 56, "num_beams": 4},
							        "summarization_xsum": {"length_penalty": 1.0, "max_length": 62, "min_length": 11, "num_beams": 6},
							    }
							}
							SCREAMING_SNAKE_CASE_  :		Any				      =    {
							    "task_specific_params.summarization.length_penalty": 1.0,
							    "task_specific_params.summarization.max_length": 128,
							    "task_specific_params.summarization.min_length": 12,
							    "task_specific_params.summarization.num_beams": 4,
							    "task_specific_params.summarization_cnn.length_penalty": 2.0,
							    "task_specific_params.summarization_cnn.max_length": 142,
							    "task_specific_params.summarization_cnn.min_length": 56,
							    "task_specific_params.summarization_cnn.num_beams": 4,
							    "task_specific_params.summarization_xsum.length_penalty": 1.0,
							    "task_specific_params.summarization_xsum.max_length": 62,
							    "task_specific_params.summarization_xsum.min_length": 11,
							    "task_specific_params.summarization_xsum.num_beams": 6,
							}

							self.assertEqual(flatten_dict(_A    ),_A    )

					def 				__UpperCamelCase   (    self      :       str    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Dict				      =    np.random.randn(3,4    )
							self.assertTrue(np.allclose(transpose(_A    ),x.transpose()    )    )

							SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.random.randn(3,4,5    )
							self.assertTrue(np.allclose(transpose(_A,axes=(1, 2, 0)    ),x.transpose((1, 2, 0)    )    )    )

					@require_torch
					def 				__UpperCamelCase   (    self      :       List[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Any				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(transpose(_A    ),transpose(_A    ).numpy()    )    )

							SCREAMING_SNAKE_CASE_  :		Dict				      =    np.random.randn(3,4,5    )
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(transpose(_A,axes=(1, 2, 0)    ),transpose(_A,axes=(1, 2, 0)    ).numpy()    )    )

					@require_tf
					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    tf.constant(_A    )
							self.assertTrue(np.allclose(transpose(_A    ),transpose(_A    ).numpy()    )    )

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

					@require_flax
					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		str				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(transpose(_A    ),np.asarray(transpose(_A    )    )    )    )

							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    np.random.randn(3,4,5    )
							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(transpose(_A,axes=(1, 2, 0)    ),np.asarray(transpose(_A,axes=(1, 2, 0)    )    )    )    )

					def 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.random.randn(3,4    )
							self.assertTrue(np.allclose(reshape(_A,(4, 3)    ),np.reshape(_A,(4, 3)    )    )    )

							SCREAMING_SNAKE_CASE_  :		Any				      =    np.random.randn(3,4,5    )
							self.assertTrue(np.allclose(reshape(_A,(12, 5)    ),np.reshape(_A,(12, 5)    )    )    )

					@require_torch
					def 				__UpperCamelCase   (    self      :       Optional[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(reshape(_A,(4, 3)    ),reshape(_A,(4, 3)    ).numpy()    )    )

							SCREAMING_SNAKE_CASE_  :		Dict				      =    np.random.randn(3,4,5    )
							SCREAMING_SNAKE_CASE_  :		int				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(reshape(_A,(12, 5)    ),reshape(_A,(12, 5)    ).numpy()    )    )

					@require_tf
					def 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    tf.constant(_A    )
							self.assertTrue(np.allclose(reshape(_A,(4, 3)    ),reshape(_A,(4, 3)    ).numpy()    )    )

							SCREAMING_SNAKE_CASE_  :		int				      =    np.random.randn(3,4,5    )
							SCREAMING_SNAKE_CASE_  :		Any				      =    tf.constant(_A    )
							self.assertTrue(np.allclose(reshape(_A,(12, 5)    ),reshape(_A,(12, 5)    ).numpy()    )    )

					@require_flax
					def 				__UpperCamelCase   (    self      :       Tuple    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		int				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(reshape(_A,(4, 3)    ),np.asarray(reshape(_A,(4, 3)    )    )    )    )

							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    np.random.randn(3,4,5    )
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(reshape(_A,(12, 5)    ),np.asarray(reshape(_A,(12, 5)    )    )    )    )

					def 				__UpperCamelCase   (    self      :       Optional[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		int				      =    np.random.randn(1,3,4    )
							self.assertTrue(np.allclose(squeeze(_A    ),np.squeeze(_A    )    )    )

							SCREAMING_SNAKE_CASE_  :		Any				      =    np.random.randn(1,4,1,5    )
							self.assertTrue(np.allclose(squeeze(_A,axis=2    ),np.squeeze(_A,axis=2    )    )    )

					@require_torch
					def 				__UpperCamelCase   (    self      :       List[str]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    np.random.randn(1,3,4    )
							SCREAMING_SNAKE_CASE_  :		Any				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(squeeze(_A    ),squeeze(_A    ).numpy()    )    )

							SCREAMING_SNAKE_CASE_  :		Any				      =    np.random.randn(1,4,1,5    )
							SCREAMING_SNAKE_CASE_  :		Dict				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(squeeze(_A,axis=2    ),squeeze(_A,axis=2    ).numpy()    )    )

					@require_tf
					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		str				      =    np.random.randn(1,3,4    )
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    tf.constant(_A    )
							self.assertTrue(np.allclose(squeeze(_A    ),squeeze(_A    ).numpy()    )    )

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

					@require_flax
					def 				__UpperCamelCase   (    self      :       List[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    np.random.randn(1,3,4    )
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(squeeze(_A    ),np.asarray(squeeze(_A    )    )    )    )

							SCREAMING_SNAKE_CASE_  :		str				      =    np.random.randn(1,4,1,5    )
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(squeeze(_A,axis=2    ),np.asarray(squeeze(_A,axis=2    )    )    )    )

					def 				__UpperCamelCase   (    self      :       List[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.random.randn(3,4    )
							self.assertTrue(np.allclose(expand_dims(_A,axis=1    ),np.expand_dims(_A,axis=1    )    )    )

					@require_torch
					def 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    torch.tensor(_A    )
							self.assertTrue(np.allclose(expand_dims(_A,axis=1    ),expand_dims(_A,axis=1    ).numpy()    )    )

					@require_tf
					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    tf.constant(_A    )
							self.assertTrue(np.allclose(expand_dims(_A,axis=1    ),expand_dims(_A,axis=1    ).numpy()    )    )






					@require_flax
					def 				__UpperCamelCase   (    self      :       List[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		int				      =    np.random.randn(3,4    )
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    jnp.array(_A    )
							self.assertTrue(np.allclose(expand_dims(_A,axis=1    ),np.asarray(expand_dims(_A,axis=1    )    )    )    )
