
from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

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 TF_MODEL_FOR_PRETRAINING_MAPPING
      from transformers.models.albert.modeling_tf_albert import (
          TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFAlbertForMaskedLM,
          TFAlbertForMultipleChoice,
          TFAlbertForPreTraining,
          TFAlbertForQuestionAnswering,
          TFAlbertForSequenceClassification,
          TFAlbertForTokenClassification,
          TFAlbertModel,
      )

class 		lowercase_  :

 def __init__(      self     ,	__UpperCamelCase     ,	__UpperCamelCase=1_3     ,	__UpperCamelCase=7     ,	__UpperCamelCase=True     ,	__UpperCamelCase=True     ,	__UpperCamelCase=True     ,	__UpperCamelCase=True     ,	__UpperCamelCase=9_9     ,	__UpperCamelCase=1_6     ,	__UpperCamelCase=3_2     ,	__UpperCamelCase=2     ,	__UpperCamelCase=4     ,	__UpperCamelCase=3_7     ,	__UpperCamelCase="gelu"     ,	__UpperCamelCase=0.1     ,	__UpperCamelCase=0.1     ,	__UpperCamelCase=5_1_2     ,	__UpperCamelCase=1_6     ,	__UpperCamelCase=2     ,	__UpperCamelCase=0.02     ,	__UpperCamelCase=3     ,	__UpperCamelCase=4     ,	__UpperCamelCase=None     ,	):




        """simple docstring"""


        UpperCamelCase_							       =       parent
        UpperCamelCase_							       =       1_3
        UpperCamelCase_							       =       7
        UpperCamelCase_							       =       True
        UpperCamelCase_							       =       True
        UpperCamelCase_							       =       True
        UpperCamelCase_							       =       True
        UpperCamelCase_							       =       9_9
        UpperCamelCase_							       =       1_6
        UpperCamelCase_							       =       3_2
        UpperCamelCase_							       =       2
        UpperCamelCase_							       =       4
        UpperCamelCase_							       =       3_7
        UpperCamelCase_							       =       """gelu"""
        UpperCamelCase_							       =       0.1
        UpperCamelCase_							       =       0.1
        UpperCamelCase_							       =       5_1_2
        UpperCamelCase_							       =       1_6
        UpperCamelCase_							       =       2
        UpperCamelCase_							       =       0.02
        UpperCamelCase_							       =       3
        UpperCamelCase_							       =       4
        UpperCamelCase_							       =       None

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


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

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

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

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

        UpperCamelCase_							       =       AlbertConfig(
            vocab_size=self.vocab_size     ,	hidden_size=self.hidden_size     ,	embedding_size=self.embedding_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     ,	initializer_range=self.initializer_range     ,	)

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

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       TFAlbertModel(config=lowerCamelCase_     )
        # inputs = {'input_ids': input_ids,
        #           'attention_mask': input_mask,
        #           'token_type_ids': token_type_ids}
        # sequence_output, pooled_output = model(**inputs)
        UpperCamelCase_							       =       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
        UpperCamelCase_							       =       model(lowerCamelCase_     )

        UpperCamelCase_							       =       [input_ids, input_mask]
        UpperCamelCase_							       =       model(lowerCamelCase_     )

        UpperCamelCase_							       =       model(lowerCamelCase_     )

        self.parent.assertEqual(result.last_hidden_state.shape     ,	(self.batch_size, self.seq_length, self.hidden_size)     )
        self.parent.assertEqual(result.pooler_output.shape     ,	(self.batch_size, self.hidden_size)     )

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.num_labels
        UpperCamelCase_							       =       TFAlbertForPreTraining(config=lowerCamelCase_     )
        UpperCamelCase_							       =       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
        UpperCamelCase_							       =       model(lowerCamelCase_     )
        self.parent.assertEqual(result.prediction_logits.shape     ,	(self.batch_size, self.seq_length, self.vocab_size)     )
        self.parent.assertEqual(result.sop_logits.shape     ,	(self.batch_size, self.num_labels)     )

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       TFAlbertForMaskedLM(config=lowerCamelCase_     )
        UpperCamelCase_							       =       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
        UpperCamelCase_							       =       model(lowerCamelCase_     )
        self.parent.assertEqual(result.logits.shape     ,	(self.batch_size, self.seq_length, self.vocab_size)     )

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.num_labels
        UpperCamelCase_							       =       TFAlbertForSequenceClassification(config=lowerCamelCase_     )
        UpperCamelCase_							       =       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
        UpperCamelCase_							       =       model(lowerCamelCase_     )
        self.parent.assertEqual(result.logits.shape     ,	(self.batch_size, self.num_labels)     )

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       TFAlbertForQuestionAnswering(config=lowerCamelCase_     )
        UpperCamelCase_							       =       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
        UpperCamelCase_							       =       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 lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.num_choices
        UpperCamelCase_							       =       TFAlbertForMultipleChoice(config=lowerCamelCase_     )
        UpperCamelCase_							       =       tf.tile(tf.expand_dims(lowerCamelCase_     ,	1     )     ,	(1, self.num_choices, 1)     )
        UpperCamelCase_							       =       tf.tile(tf.expand_dims(lowerCamelCase_     ,	1     )     ,	(1, self.num_choices, 1)     )
        UpperCamelCase_							       =       tf.tile(tf.expand_dims(lowerCamelCase_     ,	1     )     ,	(1, self.num_choices, 1)     )
        UpperCamelCase_							       =       {
            """input_ids""": multiple_choice_inputs_ids,
            """attention_mask""": multiple_choice_input_mask,
            """token_type_ids""": multiple_choice_token_type_ids,
        }
        UpperCamelCase_							       =       model(lowerCamelCase_     )
        self.parent.assertListEqual(list(result["""logits"""].shape     )     ,	[self.batch_size, self.num_choices]     )

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.num_labels
        UpperCamelCase_							       =       TFAlbertForTokenClassification(config=lowerCamelCase_     )
        UpperCamelCase_							       =       {
            """input_ids""": input_ids,
            """attention_mask""": input_mask,
            """token_type_ids""": token_type_ids,
        }
        UpperCamelCase_							       =       model(lowerCamelCase_     )
        self.parent.assertListEqual(list(result["""logits"""].shape     )     ,	[self.batch_size, self.seq_length, self.num_labels]     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


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



@require_tf
class 		lowercase_  (       lowerCAmelCase_							,	lowerCAmelCase_							,	unittest.TestCase				):
 A__						:				Any         =    (
     (
         TFAlbertModel,
         TFAlbertForPreTraining,
         TFAlbertForMaskedLM,
         TFAlbertForSequenceClassification,
         TFAlbertForQuestionAnswering,
         TFAlbertForTokenClassification,
         TFAlbertForMultipleChoice,
     )
     if is_tf_available()
     else ()
 )
 A__						:				int         =    (
     {
         'feature-extraction': TFAlbertModel,
         'fill-mask': TFAlbertForMaskedLM,
         'question-answering': TFAlbertForQuestionAnswering,
         'text-classification': TFAlbertForSequenceClassification,
         'token-classification': TFAlbertForTokenClassification,
         'zero-shot': TFAlbertForSequenceClassification,
     }
     if is_tf_available()
     else {}
 )
 A__						:				List[str]         =    False
 A__						:				Optional[Any]         =    False

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase     ,	__UpperCamelCase=False     ):




        """simple docstring"""


        UpperCamelCase_							       =       super()._prepare_for_class(lowerCamelCase_     ,	lowerCamelCase_     ,	return_labels=lowerCamelCase_     )

        if return_labels:
               if model_class in get_values(lowerCamelCase_     ):
                      UpperCamelCase_							       =       tf.zeros(self.model_tester.batch_size     ,	dtype=tf.intaa     )

        return inputs_dict

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       TFAlbertModelTester(self     )
        UpperCamelCase_							       =       ConfigTester(self     ,	config_class=lowerCamelCase_     ,	hidden_size=3_7     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        self.config_tester.run_common_tests()

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_model(*lowerCamelCase_     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_pretraining(*lowerCamelCase_     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_masked_lm(*lowerCamelCase_     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_multiple_choice(*lowerCamelCase_     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_sequence_classification(*lowerCamelCase_     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_question_answering(*lowerCamelCase_     )

 @slow
 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               UpperCamelCase_							       =       TFAlbertModel.from_pretrained(lowerCamelCase_     )
               self.assertIsNotNone(lowerCamelCase_     )



@require_tf
class 		lowercase_  (       unittest.TestCase				):

 @slow
 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       TFAlbertForPreTraining.from_pretrained("""albert-base-v2"""     )
        UpperCamelCase_							       =       tf.constant([[0, 1, 2, 3, 4, 5]]     )
        UpperCamelCase_							       =       model(lowerCamelCase_     )[0]

        UpperCamelCase_							       =       [1, 6, 3_0_0_0_0]
        self.assertEqual(output.shape     ,	lowerCamelCase_     )

        UpperCamelCase_							       =       tf.constant(
            [
                [
                    [4.595_668, 0.74_462_754, -1.818_147],
                    [4.5_954_347, 0.7_454_184, -1.8_188_258],
                    [4.5_954_905, 0.7_448_235, -1.8_182_316],
                ]
            ]     )
        tf.debugging.assert_near(output[:, :3, :3]     ,	lowerCamelCase_     ,	atol=1e-4     )





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 ViltImageProcessor

class 		lowercase_       (       unittest.TestCase				):

 def __init__(      self     ,	__UpperCamelCase     ,	__UpperCamelCase=7     ,	__UpperCamelCase=3     ,	__UpperCamelCase=1_8     ,	__UpperCamelCase=3_0     ,	__UpperCamelCase=4_0_0     ,	__UpperCamelCase=True     ,	__UpperCamelCase=None     ,	__UpperCamelCase=2     ,	__UpperCamelCase=True     ,	__UpperCamelCase=[0.5, 0.5, 0.5]     ,	__UpperCamelCase=[0.5, 0.5, 0.5]     ,	):




        """simple docstring"""


        UpperCamelCase_							       =       size if size is not None else {"""shortest_edge""": 3_0}
        UpperCamelCase_							       =       parent
        UpperCamelCase_							       =       batch_size
        UpperCamelCase_							       =       num_channels
        UpperCamelCase_							       =       image_size
        UpperCamelCase_							       =       min_resolution
        UpperCamelCase_							       =       max_resolution
        UpperCamelCase_							       =       do_resize
        UpperCamelCase_							       =       size
        UpperCamelCase_							       =       size_divisor
        UpperCamelCase_							       =       do_normalize
        UpperCamelCase_							       =       image_mean
        UpperCamelCase_							       =       image_std

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        return {
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_normalize": self.do_normalize,
            "do_resize": self.do_resize,
            "size": self.size,
            "size_divisor": self.size_divisor,
        }

 def lowerCamelCase_				(      self     ,	__UpperCamelCase     ,	__UpperCamelCase=False     ):




        """simple docstring"""


        if not batched:
               UpperCamelCase_							       =       self.size["""shortest_edge"""]
               UpperCamelCase_							       =       image_inputs[0]
               if isinstance(__UpperCamelCase     ,	Image.Image     ):
                      UpperCamelCase_       ,				UpperCamelCase_							       =       image.size
               else:
                      UpperCamelCase_       ,				UpperCamelCase_							       =       image.shape[1], image.shape[2]
               UpperCamelCase_							       =       size / min(__UpperCamelCase     ,	__UpperCamelCase     )
               if h < w:
                      UpperCamelCase_       ,				UpperCamelCase_							       =       size, scale * w
               else:
                      UpperCamelCase_       ,				UpperCamelCase_							       =       scale * h, size

               UpperCamelCase_							       =       int((1_3_3_3 / 8_0_0) * size     )
               if max(__UpperCamelCase     ,	__UpperCamelCase     ) > max_size:
                      UpperCamelCase_							       =       max_size / max(__UpperCamelCase     ,	__UpperCamelCase     )
                      UpperCamelCase_							       =       newh * scale
                      UpperCamelCase_							       =       neww * scale

               UpperCamelCase_       ,				UpperCamelCase_							       =       int(newh + 0.5     ), int(neww + 0.5     )
               UpperCamelCase_       ,				UpperCamelCase_							       =       (
                   newh // self.size_divisor * self.size_divisor,
                   neww // self.size_divisor * self.size_divisor,
               )

        else:
               UpperCamelCase_							       =       []
               for image in image_inputs:
                      UpperCamelCase_       ,				UpperCamelCase_							       =       self.get_expected_values([image]     )
                      expected_values.append((expected_height, expected_width)     )
               UpperCamelCase_							       =       max(__UpperCamelCase     ,	key=lambda __UpperCamelCase     : item[0]     )[0]
               UpperCamelCase_							       =       max(__UpperCamelCase     ,	key=lambda __UpperCamelCase     : item[1]     )[1]

        return expected_height, expected_width



@require_torch
@require_vision
class 		lowercase_       (       __SCREAMING_SNAKE_CASE							,	unittest.TestCase				):
 A__						:				Optional[int]         =    ViltImageProcessor if is_vision_available() else None

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       ViltImageProcessingTester(self     )

 @property
 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        return self.image_processor_tester.prepare_image_processor_dict()

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.image_processing_class(**self.image_processor_dict     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""image_mean"""     )     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""image_std"""     )     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""do_normalize"""     )     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""do_resize"""     )     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""size"""     )     )
        self.assertTrue(hasattr(__UpperCamelCase     ,	"""size_divisor"""     )     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.image_processing_class.from_dict(self.image_processor_dict     )
        self.assertEqual(image_processor.size     ,	{"""shortest_edge""": 3_0}     )

        UpperCamelCase_							       =       self.image_processing_class.from_dict(self.image_processor_dict     ,	size=4_2     )
        self.assertEqual(image_processor.size     ,	{"""shortest_edge""": 4_2}     )

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        pass

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.image_processing_class(**self.image_processor_dict     )
        # create random PIL images
        UpperCamelCase_							       =       prepare_image_inputs(self.image_processor_tester     ,	equal_resolution=__UpperCamelCase     )
        for image in image_inputs:
               self.assertIsInstance(__UpperCamelCase     ,	Image.Image     )

        # Test not batched input
        UpperCamelCase_							       =       image_processing(image_inputs[0]     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)     ,	)

        # Test batched
        UpperCamelCase_							       =       image_processing(__UpperCamelCase     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     ,	batched=__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )     ,	)

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.image_processing_class(**self.image_processor_dict     )
        # create random numpy tensors
        UpperCamelCase_							       =       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
        UpperCamelCase_							       =       image_processing(image_inputs[0]     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)     ,	)

        # Test batched
        UpperCamelCase_							       =       image_processing(__UpperCamelCase     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     ,	batched=__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )     ,	)

 def lowerCamelCase_				(      self     ):




        """simple docstring"""


        UpperCamelCase_							       =       self.image_processing_class(**self.image_processor_dict     )
        # create random PyTorch tensors
        UpperCamelCase_							       =       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
        UpperCamelCase_							       =       image_processing(image_inputs[0]     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)     ,	)

        # Test batched
        UpperCamelCase_							       =       image_processing(__UpperCamelCase     ,	return_tensors="""pt"""     ).pixel_values

        UpperCamelCase_       ,				UpperCamelCase_							       =       self.image_processor_tester.get_expected_values(__UpperCamelCase     ,	batched=__UpperCamelCase     )
        self.assertEqual(
            encoded_images.shape     ,	(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )     ,	)



