"""simple docstring"""
import unittest

from transformers import ElectraConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
					import torch

					from transformers import (
					    MODEL_FOR_PRETRAINING_MAPPING,
					    ElectraForCausalLM,
					    ElectraForMaskedLM,
					    ElectraForMultipleChoice,
					    ElectraForPreTraining,
					    ElectraForQuestionAnswering,
					    ElectraForSequenceClassification,
					    ElectraForTokenClassification,
					    ElectraModel,
					)
					from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST



class 	lowerCAmelCase_     :



				"""simple docstring"""

				def __init__(					self		,     lowerCAmelCase		,     lowerCAmelCase=13		,     lowerCAmelCase=7		,     lowerCAmelCase=True		,     lowerCAmelCase=True		,     lowerCAmelCase=True		,     lowerCAmelCase=True		,     lowerCAmelCase=99		,     lowerCAmelCase=32		,     lowerCAmelCase=5		,     lowerCAmelCase=4		,     lowerCAmelCase=37		,     lowerCAmelCase="gelu"		,     lowerCAmelCase=0.1		,     lowerCAmelCase=0.1		,     lowerCAmelCase=5_12		,     lowerCAmelCase=16		,     lowerCAmelCase=2		,     lowerCAmelCase=0.02		,     lowerCAmelCase=3		,     lowerCAmelCase=4		,     lowerCAmelCase=None		,     ):






										"""simple docstring"""

										snake_case             =      parent
										snake_case             =      batch_size
										snake_case             =      seq_length
										snake_case             =      is_training
										snake_case             =      use_input_mask
										snake_case             =      use_token_type_ids
										snake_case             =      use_labels
										snake_case             =      vocab_size
										snake_case             =      hidden_size
										snake_case             =      num_hidden_layers
										snake_case             =      num_attention_heads
										snake_case             =      intermediate_size
										snake_case             =      hidden_act
										snake_case             =      hidden_dropout_prob
										snake_case             =      attention_probs_dropout_prob
										snake_case             =      max_position_embeddings
										snake_case             =      type_vocab_size
										snake_case             =      type_sequence_label_size
										snake_case             =      initializer_range
										snake_case             =      num_labels
										snake_case             =      num_choices
										snake_case             =      scope

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      ids_tensor([self.batch_size, self.seq_length]		,     self.vocab_size     )

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

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

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

										snake_case             =      self.get_config()

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

				def 		snake_case			(					self     ):






										"""simple docstring"""

										return ElectraConfig(
										    vocab_size=self.vocab_size		,     hidden_size=self.hidden_size		,     num_hidden_layers=self.num_hidden_layers		,     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		,     max_position_embeddings=self.max_position_embeddings		,     type_vocab_size=self.type_vocab_size		,     is_decoder=lowerCAmelCase		,     initializer_range=self.initializer_range		,     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										(
										    (
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,
										)             =      self.prepare_config_and_inputs()

										snake_case             =      True
										snake_case             =      floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
										snake_case             =      ids_tensor([self.batch_size, self.seq_length]		,     vocab_size=2     )

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

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      ElectraModel(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase     )
										snake_case             =      model(lowerCAmelCase		,     token_type_ids=lowerCAmelCase     )
										snake_case             =      model(lowerCAmelCase     )
										self.parent.assertEqual(result.last_hidden_state.shape		,     (self.batch_size, self.seq_length, self.hidden_size)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      True
										snake_case             =      ElectraModel(lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(
										    lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     encoder_hidden_states=lowerCAmelCase		,     encoder_attention_mask=lowerCAmelCase		,     )
										snake_case             =      model(
										    lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     encoder_hidden_states=lowerCAmelCase		,     )
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase     )
										self.parent.assertEqual(result.last_hidden_state.shape		,     (self.batch_size, self.seq_length, self.hidden_size)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      ElectraForMaskedLM(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length, self.vocab_size)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      ElectraForCausalLM(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length, self.vocab_size)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      self.num_labels
										snake_case             =      ElectraForTokenClassification(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length, self.num_labels)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      self.num_labels
										snake_case             =      ElectraForPreTraining(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      self.num_labels
										snake_case             =      ElectraForSequenceClassification(lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.num_labels)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      ElectraForQuestionAnswering(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      model(
										    lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     start_positions=lowerCAmelCase		,     end_positions=lowerCAmelCase		,     )
										self.parent.assertEqual(result.start_logits.shape		,     (self.batch_size, self.seq_length)     )
										self.parent.assertEqual(result.end_logits.shape		,     (self.batch_size, self.seq_length)     )

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase		,     ):






										"""simple docstring"""

										snake_case             =      self.num_choices
										snake_case             =      ElectraForMultipleChoice(config=lowerCAmelCase     )
										model.to(lowerCAmelCase     )
										model.eval()
										snake_case             =      input_ids.unsqueeze(1     ).expand(-1		,     self.num_choices		,     -1     ).contiguous()
										snake_case             =      token_type_ids.unsqueeze(1     ).expand(-1		,     self.num_choices		,     -1     ).contiguous()
										snake_case             =      input_mask.unsqueeze(1     ).expand(-1		,     self.num_choices		,     -1     ).contiguous()
										snake_case             =      model(
										    lowerCAmelCase		,     attention_mask=lowerCAmelCase		,     token_type_ids=lowerCAmelCase		,     labels=lowerCAmelCase		,     )
										self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.num_choices)     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.prepare_config_and_inputs()
										(
										    (
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,(
										    snake_case
										)       ,
										)             =      config_and_inputs
										snake_case             =      {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
										return config, inputs_dict





@require_torch
class 	lowerCAmelCase_     (      lowerCAmelCase  ,     lowerCAmelCase  ,     unittest.TestCase       ):



				"""simple docstring"""
				_lowerCAmelCase  :     Optional[int]      	=    (
				    (
				        ElectraModel,
				        ElectraForPreTraining,
				        ElectraForMaskedLM,
				        ElectraForCausalLM,
				        ElectraForMultipleChoice,
				        ElectraForTokenClassification,
				        ElectraForSequenceClassification,
				        ElectraForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				_lowerCAmelCase  :     Optional[int]      	=    (
				    {
				        """feature-extraction""": ElectraModel,
				        """fill-mask""": ElectraForMaskedLM,
				        """question-answering""": ElectraForQuestionAnswering,
				        """text-classification""": ElectraForSequenceClassification,
				        """text-generation""": ElectraForCausalLM,
				        """token-classification""": ElectraForTokenClassification,
				        """zero-shot""": ElectraForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				_lowerCAmelCase  :     Union[str, Any]      	=    True

				def 		snake_case			(					self		,     lowerCAmelCase		,     lowerCAmelCase		,     lowerCAmelCase=False     ):






										"""simple docstring"""

										snake_case             =      super()._prepare_for_class(lowerCAmelCase		,     lowerCAmelCase		,     return_labels=lowerCAmelCase     )

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

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      ElectraModelTester(self     )
										snake_case             =      ConfigTester(self		,     config_class=lowerCAmelCase		,     hidden_size=37     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										self.config_tester.run_common_tests()

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_model(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs_for_decoder()
										self.model_tester.create_and_check_electra_model_as_decoder(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										for type in ["absolute", "relative_key", "relative_key_query"]:
																snake_case             =      type
																self.model_tester.create_and_check_electra_model(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_masked_lm(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_token_classification(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_pretraining(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_sequence_classification(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_question_answering(*lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_multiple_choice(*lowerCAmelCase     )

				@slow
				def 		snake_case			(					self     ):






										"""simple docstring"""

										for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																snake_case             =      ElectraModel.from_pretrained(lowerCAmelCase     )
																self.assertIsNotNone(lowerCAmelCase     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.model_tester.prepare_config_and_inputs_for_decoder()
										self.model_tester.create_and_check_electra_for_causal_lm(*lowerCAmelCase     )





@require_torch
class 	lowerCAmelCase_     (      unittest.TestCase       ):



				"""simple docstring"""

				@slow
				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      ElectraModel.from_pretrained('google/electra-small-discriminator'     )
										snake_case             =      torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]     )
										snake_case             =      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]     )
										snake_case             =      model(lowerCAmelCase		,     attention_mask=lowerCAmelCase     )[0]
										snake_case             =      torch.Size((1, 11, 2_56)     )
										self.assertEqual(output.shape		,     lowerCAmelCase     )
										snake_case             =      torch.tensor(
										    [[[0.44_71, 0.68_21, -0.32_65], [0.46_27, 0.52_55, -0.36_68], [0.45_32, 0.33_13, -0.43_44]]]     )

										self.assertTrue(torch.allclose(output[:, 1:4, 1:4]		,     lowerCAmelCase		,     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


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import SwinaSRImageProcessor
					from transformers.image_transforms import get_image_size



class 	lowerCAmelCase_     (      unittest.TestCase       ):



				"""simple docstring"""

				def __init__(					self		,     lowerCAmelCase		,     lowerCAmelCase=7		,     lowerCAmelCase=3		,     lowerCAmelCase=18		,     lowerCAmelCase=30		,     lowerCAmelCase=4_00		,     lowerCAmelCase=True		,     lowerCAmelCase=1 / 2_55		,     lowerCAmelCase=True		,     lowerCAmelCase=8		,     ):






										"""simple docstring"""

										snake_case             =      parent
										snake_case             =      batch_size
										snake_case             =      num_channels
										snake_case             =      image_size
										snake_case             =      min_resolution
										snake_case             =      max_resolution
										snake_case             =      do_rescale
										snake_case             =      rescale_factor
										snake_case             =      do_pad
										snake_case             =      pad_size

				def 		snake_case			(					self     ):






										"""simple docstring"""

										return {
										    "do_rescale": self.do_rescale,
										    "rescale_factor": self.rescale_factor,
										    "do_pad": self.do_pad,
										    "pad_size": self.pad_size,
										}

				def 		snake_case			(					self		,     lowerCAmelCase=False		,     lowerCAmelCase=False		,     lowerCAmelCase=False     ):






										"""simple docstring"""

										assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

										if equal_resolution:
																snake_case             =      []
																for i in range(self.batch_size     ):
																						image_inputs.append(
																						    np.random.randint(
																						        2_55		,     size=(self.num_channels, self.max_resolution, self.max_resolution)		,     dtype=np.uinta     )     )
										else:
																snake_case             =      []
																for i in range(self.batch_size     ):
																						snake_case       ,snake_case             =      np.random.choice(np.arange(self.min_resolution		,     self.max_resolution     )		,     2     )
																						image_inputs.append(np.random.randint(2_55		,     size=(self.num_channels, width, height)		,     dtype=np.uinta     )     )

										if not numpify and not torchify:
																# PIL expects the channel dimension as last dimension
																snake_case             =      [Image.fromarray(np.moveaxis(lowerCAmelCase		,     0		,     -1     )     ) for x in image_inputs]

										if torchify:
																snake_case             =      [torch.from_numpy(lowerCAmelCase     ) for x in image_inputs]

										return image_inputs





@require_torch
@require_vision
class 	lowerCAmelCase_     (      lowerCAmelCase  ,     unittest.TestCase       ):



				"""simple docstring"""
				_lowerCAmelCase  :     Tuple      	=    SwinaSRImageProcessor if is_vision_available() else None

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      SwinaSRImageProcessingTester(self     )

				@property
				def 		snake_case			(					self     ):






										"""simple docstring"""

										return self.image_processor_tester.prepare_image_processor_dict()

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.image_processing_class(**self.image_processor_dict     )
										self.assertTrue(hasattr(lowerCAmelCase		,     'do_rescale'     )     )
										self.assertTrue(hasattr(lowerCAmelCase		,     'rescale_factor'     )     )
										self.assertTrue(hasattr(lowerCAmelCase		,     'do_pad'     )     )
										self.assertTrue(hasattr(lowerCAmelCase		,     'pad_size'     )     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										pass

				def 		snake_case			(					self		,     lowerCAmelCase     ):






										"""simple docstring"""

										snake_case       ,snake_case             =      get_image_size(lowerCAmelCase     )
										snake_case             =      self.image_processor_tester.pad_size

										snake_case             =      (old_height // size + 1) * size - old_height
										snake_case             =      (old_width // size + 1) * size - old_width
										return old_height + pad_height, old_width + pad_width

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.image_processing_class(**self.image_processor_dict     )
										# create random PIL images
										snake_case             =      self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase		,     Image.Image     )

										# Test not batched input
										snake_case             =      image_processor(image_inputs[0]		,     return_tensors='pt'     ).pixel_values
										snake_case       ,snake_case             =      self.calculate_expected_size(np.array(image_inputs[0]     )     )
										self.assertEqual(
										    encoded_images.shape		,     (
										        1,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )		,     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.image_processing_class(**self.image_processor_dict     )
										# create random numpy tensors
										snake_case             =      self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase		,     numpify=lowerCAmelCase     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase		,     np.ndarray     )

										# Test not batched input
										snake_case             =      image_processor(image_inputs[0]		,     return_tensors='pt'     ).pixel_values
										snake_case       ,snake_case             =      self.calculate_expected_size(image_inputs[0]     )
										self.assertEqual(
										    encoded_images.shape		,     (
										        1,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )		,     )

				def 		snake_case			(					self     ):






										"""simple docstring"""

										snake_case             =      self.image_processing_class(**self.image_processor_dict     )
										# create random PyTorch tensors
										snake_case             =      self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase		,     torchify=lowerCAmelCase     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase		,     torch.Tensor     )

										# Test not batched input
										snake_case             =      image_processor(image_inputs[0]		,     return_tensors='pt'     ).pixel_values
										snake_case       ,snake_case             =      self.calculate_expected_size(image_inputs[0]     )
										self.assertEqual(
										    encoded_images.shape		,     (
										        1,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )		,     )


