



'''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    _snake_case   :

					"""simple docstring"""





					def __init__(     self   , UpperCAmelCase__   , UpperCAmelCase__=13   , UpperCAmelCase__=7   , UpperCAmelCase__=True   , UpperCAmelCase__=True   , UpperCAmelCase__=True   , UpperCAmelCase__=True   , UpperCAmelCase__=99   , UpperCAmelCase__=[1, 1, 2]   , UpperCAmelCase__=1   , UpperCAmelCase__=32   , UpperCAmelCase__=4   , UpperCAmelCase__=8   , UpperCAmelCase__=37   , UpperCAmelCase__="gelu_new"   , UpperCAmelCase__=0.1   , UpperCAmelCase__=0.1   , UpperCAmelCase__=0.0   , UpperCAmelCase__=512   , UpperCAmelCase__=3   , UpperCAmelCase__=0.0_2   , UpperCAmelCase__=3   , UpperCAmelCase__=4   , UpperCAmelCase__=None   , UpperCAmelCase__=False   , )      ->	List[Any]:
										a_									=   parent
										a_									=   batch_size
										a_									=   seq_length
										a_									=   is_training
										a_									=   use_input_mask
										a_									=   use_token_type_ids
										a_									=   use_labels
										a_									=   vocab_size
										a_									=   block_sizes
										a_									=   num_decoder_layers
										a_									=   d_model
										a_									=   n_head
										a_									=   d_head
										a_									=   d_inner
										a_									=   hidden_act
										a_									=   hidden_dropout
										a_									=   attention_dropout
										a_									=   activation_dropout
										a_									=   max_position_embeddings
										a_									=   type_vocab_size
										a_									=   2
										a_									=   num_labels
										a_									=   num_choices
										a_									=   scope
										a_									=   initializer_std

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




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Union[str, Any]:
										a_									=   ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size     )

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

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

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

										a_									=   self.get_config()

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




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Optional[int]:
										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  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	Dict:
										a_									=   FunnelModel(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__     )
										a_									=   model(UpperCAmelCase__   , token_type_ids=UpperCAmelCase__     )
										a_									=   model(UpperCAmelCase__     )
										self.parent.assertEqual(result.last_hidden_state.shape   , (self.batch_size, self.seq_length, self.d_model)     )

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

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




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	Any:
										a_									=   FunnelBaseModel(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__     )
										a_									=   model(UpperCAmelCase__   , token_type_ids=UpperCAmelCase__     )
										a_									=   model(UpperCAmelCase__     )
										self.parent.assertEqual(result.last_hidden_state.shape   , (self.batch_size, 2, self.d_model)     )

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

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




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	List[str]:
										a_									=   self.num_labels
										a_									=   FunnelForPreTraining(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , labels=UpperCAmelCase__     )
										self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.seq_length)     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	Any:
										a_									=   FunnelForMaskedLM(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , labels=UpperCAmelCase__     )
										self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.seq_length, self.vocab_size)     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	List[Any]:
										a_									=   self.num_labels
										a_									=   FunnelForSequenceClassification(UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , labels=UpperCAmelCase__     )
										self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.num_labels)     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	Dict:
										a_									=   self.num_choices
										a_									=   FunnelForMultipleChoice(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   input_ids.unsqueeze(1     ).expand(-1   , self.num_choices   , -1     ).contiguous()
										a_									=   token_type_ids.unsqueeze(1     ).expand(-1   , self.num_choices   , -1     ).contiguous()
										a_									=   input_mask.unsqueeze(1     ).expand(-1   , self.num_choices   , -1     ).contiguous()
										a_									=   model(
										    UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , labels=UpperCAmelCase__   , )
										self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.num_choices)     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	str:
										a_									=   self.num_labels
										a_									=   FunnelForTokenClassification(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , labels=UpperCAmelCase__     )
										self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.seq_length, self.num_labels)     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__   , )      ->	str:
										a_									=   FunnelForQuestionAnswering(config=UpperCAmelCase__     )
										model.to(UpperCAmelCase__     )
										model.eval()
										a_									=   model(
										    UpperCAmelCase__   , attention_mask=UpperCAmelCase__   , token_type_ids=UpperCAmelCase__   , start_positions=UpperCAmelCase__   , end_positions=UpperCAmelCase__   , )
										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  __SCREAMING_SNAKE_CASE (     self     )      ->	Any:
										a_									=   self.prepare_config_and_inputs()
										(
										    a_   
										)									=   config_and_inputs
										a_									=   {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
										return config, inputs_dict



@require_torch
class    _snake_case   (				snake_case     ,					snake_case     ,					unittest.TestCase					):

					"""simple docstring"""





					_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  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__   , UpperCAmelCase__   , UpperCAmelCase__=False     )      ->	Union[str, Any]:
										a_									=   super()._prepare_for_class(UpperCAmelCase__   , UpperCAmelCase__   , return_labels=UpperCAmelCase__     )

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




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Any:
										a_									=   FunnelModelTester(self     )
										a_									=   ConfigTester(self   , config_class=UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	int:
										self.config_tester.run_common_tests()




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Dict:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Optional[int]:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_pretraining(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	List[str]:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Dict:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_token_classification(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	str:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__     )      ->	Any:






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



@require_torch
class    _snake_case   (				snake_case     ,					unittest.TestCase					):

					"""simple docstring"""





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




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	List[Any]:
										a_									=   FunnelModelTester(self   , base=UpperCAmelCase__     )
										a_									=   ConfigTester(self   , config_class=UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Tuple:
										self.config_tester.run_common_tests()




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Any:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_base_model(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	List[Any]:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Dict:
										a_									=   self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_multiple_choice(*UpperCAmelCase__     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Tuple:
										a_									=   self.model_tester.prepare_config_and_inputs_for_common()
										a_									=   True

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




					def  __SCREAMING_SNAKE_CASE (     self   , UpperCAmelCase__     )      ->	Tuple:






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



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

					"""simple docstring"""





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

										a_									=   FunnelModel.from_pretrained('sgugger/funnel-random-tiny'     )
										a_									=   model(UpperCAmelCase__   , token_type_ids=UpperCAmelCase__     )[0].abs()

										a_									=   torch.tensor(2344.8352     )
										a_									=   torch.tensor(0.8_0_5_2     )
										self.assertTrue(torch.allclose(output.sum()   , UpperCAmelCase__   , atol=1e-4     )     )
										self.assertTrue(torch.allclose(output.mean()   , UpperCAmelCase__   , atol=1e-4     )     )

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

										a_									=   torch.tensor(2343.8425     )
										a_									=   torch.tensor(0.8_0_4_9     )
										self.assertTrue(torch.allclose(output.sum()   , UpperCAmelCase__   , atol=1e-4     )     )
										self.assertTrue(torch.allclose(output.mean()   , UpperCAmelCase__   , atol=1e-4     )     )




					@slow
					def  __SCREAMING_SNAKE_CASE (     self     )      ->	str:
										a_									=   FunnelTokenizer.from_pretrained('huggingface/funnel-small'     )
										a_									=   FunnelModel.from_pretrained('huggingface/funnel-small'     )
										a_									=   tokenizer('Hello! I am the Funnel Transformer model.'   , return_tensors='pt'     )
										a_									=   model(**UpperCAmelCase__     )[0]

										a_									=   torch.tensor(2_3_5.7_2_4_6     )
										a_									=   torch.tensor(0.0_2_5_6     )
										self.assertTrue(torch.allclose(output.sum()   , UpperCAmelCase__   , atol=1e-4     )     )
										self.assertTrue(torch.allclose(output.mean()   , UpperCAmelCase__   , atol=1e-4     )     )









'''simple docstring'''
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import ConvNextImageProcessor


class    _snake_case   (				unittest.TestCase					):

					"""simple docstring"""





					def __init__(     self   , UpperCAmelCase__   , UpperCAmelCase__=7   , UpperCAmelCase__=3   , UpperCAmelCase__=18   , UpperCAmelCase__=30   , UpperCAmelCase__=400   , UpperCAmelCase__=True   , UpperCAmelCase__=None   , UpperCAmelCase__=0.8_7_5   , UpperCAmelCase__=True   , UpperCAmelCase__=[0.5, 0.5, 0.5]   , UpperCAmelCase__=[0.5, 0.5, 0.5]   , )      ->	Optional[int]:
										a_									=   size if size is not None else {'shortest_edge': 20}
										a_									=   parent
										a_									=   batch_size
										a_									=   num_channels
										a_									=   image_size
										a_									=   min_resolution
										a_									=   max_resolution
										a_									=   do_resize
										a_									=   size
										a_									=   crop_pct
										a_									=   do_normalize
										a_									=   image_mean
										a_									=   image_std




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	List[str]:
										return {
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_normalize": self.do_normalize,
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "crop_pct": self.crop_pct,
										}



@require_torch
@require_vision
class    _snake_case   (				snake_case     ,					unittest.TestCase					):

					"""simple docstring"""





					_UpperCamelCase		 =      ConvNextImageProcessor if is_vision_available() else None




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Tuple:
										a_									=   ConvNextImageProcessingTester(self     )




					@property
					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Dict:
										return self.image_processor_tester.prepare_image_processor_dict()




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Any:
										a_									=   self.image_processing_class(**self.image_processor_dict     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'do_resize'     )     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'size'     )     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'crop_pct'     )     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'do_normalize'     )     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'image_mean'     )     )
										self.assertTrue(hasattr(UpperCAmelCase__   , 'image_std'     )     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Tuple:
										a_									=   self.image_processing_class.from_dict(self.image_processor_dict     )
										self.assertEqual(image_processor.size   , {'shortest_edge': 20}     )

										a_									=   self.image_processing_class.from_dict(self.image_processor_dict   , size=42     )
										self.assertEqual(image_processor.size   , {'shortest_edge': 42}     )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Optional[Any]:
										pass




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	Tuple:
										# Initialize image_processing
										a_									=   self.image_processing_class(**self.image_processor_dict     )
										# create random PIL images
										a_									=   prepare_image_inputs(self.image_processor_tester   , equal_resolution=UpperCAmelCase__     )
										for image in image_inputs:
															self.assertIsInstance(UpperCAmelCase__   , Image.Image     )

										# Test not batched input
										a_									=   image_processing(image_inputs[0]   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )

										# Test batched
										a_									=   image_processing(UpperCAmelCase__   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	int:
										# Initialize image_processing
										a_									=   self.image_processing_class(**self.image_processor_dict     )
										# create random numpy tensors
										a_									=   prepare_image_inputs(self.image_processor_tester   , equal_resolution=UpperCAmelCase__   , numpify=UpperCAmelCase__     )
										for image in image_inputs:
															self.assertIsInstance(UpperCAmelCase__   , np.ndarray     )

										# Test not batched input
										a_									=   image_processing(image_inputs[0]   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )

										# Test batched
										a_									=   image_processing(UpperCAmelCase__   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )




					def  __SCREAMING_SNAKE_CASE (     self     )      ->	int:
										# Initialize image_processing
										a_									=   self.image_processing_class(**self.image_processor_dict     )
										# create random PyTorch tensors
										a_									=   prepare_image_inputs(self.image_processor_tester   , equal_resolution=UpperCAmelCase__   , torchify=UpperCAmelCase__     )
										for image in image_inputs:
															self.assertIsInstance(UpperCAmelCase__   , torch.Tensor     )

										# Test not batched input
										a_									=   image_processing(image_inputs[0]   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )

										# Test batched
										a_									=   image_processing(UpperCAmelCase__   , return_tensors='pt'     ).pixel_values
										self.assertEqual(
										    encoded_images.shape   , (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['shortest_edge'],
										        self.image_processor_tester.size['shortest_edge'],
										    )   , )

