

import inspect
import unittest

from transformers import ResNetConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from transformers.utils import cached_property, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor


if is_flax_available():
 import jax
 import jax.numpy as jnp

 from transformers.models.resnet.modeling_flax_resnet import FlaxResNetForImageClassification, FlaxResNetModel

if is_vision_available():
 from PIL import Image

 from transformers import AutoImageProcessor



class 					lowercase		( unittest.TestCase      ):



 '''simple docstring'''


 def __init__(self , __a , __a=3 , __a=32 , __a=3 , __a=10 , __a=[10, 20, 30, 40] , __a=[1, 1, 2, 1] , __a=True , __a=True , __a="relu" , __a=3 , __a=None , )				->      str:






  """simple docstring"""





  UpperCAmelCase__           =       parent
  UpperCAmelCase__           =       batch_size
  UpperCAmelCase__           =       image_size
  UpperCAmelCase__           =       num_channels
  UpperCAmelCase__           =       embeddings_size
  UpperCAmelCase__           =       hidden_sizes
  UpperCAmelCase__           =       depths
  UpperCAmelCase__           =       is_training
  UpperCAmelCase__           =       use_labels
  UpperCAmelCase__           =       hidden_act
  UpperCAmelCase__           =       num_labels
  UpperCAmelCase__           =       scope
  UpperCAmelCase__           =       len(__SCREAMING_SNAKE_CASE				)




 def 						UpperCamelCase__							(self				)				->      Optional[Any]:






  """simple docstring"""





  UpperCAmelCase__           =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

  UpperCAmelCase__           =       self.get_config()

  return config, pixel_values




 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  return ResNetConfig(
      num_channels=self.num_channels , embeddings_size=self.embeddings_size , hidden_sizes=self.hidden_sizes , depths=self.depths , hidden_act=self.hidden_act , num_labels=self.num_labels , image_size=self.image_size , )




 def 						UpperCamelCase__							(self , __a , __a				)				->      Dict:






  """simple docstring"""





  UpperCAmelCase__           =       FlaxResNetModel(config=__SCREAMING_SNAKE_CASE				)
  UpperCAmelCase__           =       model(__SCREAMING_SNAKE_CASE				)

  # Output shape (b, c, h, w)
  self.parent.assertEqual(
      result.last_hidden_state.shape , (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32) , )




 def 						UpperCamelCase__							(self , __a , __a				)				->      int:






  """simple docstring"""





  UpperCAmelCase__           =       self.num_labels
  UpperCAmelCase__           =       FlaxResNetForImageClassification(config=__SCREAMING_SNAKE_CASE				)
  UpperCAmelCase__           =       model(__SCREAMING_SNAKE_CASE				)
  self.parent.assertEqual(result.logits.shape , (self.batch_size, self.num_labels)				)




 def 						UpperCamelCase__							(self				)				->      List[str]:






  """simple docstring"""





  UpperCAmelCase__           =       self.prepare_config_and_inputs()
  UpperCAmelCase__       ,					UpperCAmelCase__           =       config_and_inputs
  UpperCAmelCase__           =       {'pixel_values': pixel_values}
  return config, inputs_dict







@require_flax
class 					lowercase		( lowerCAmelCase_				,       unittest.TestCase      ):



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE      							=       (FlaxResNetModel, FlaxResNetForImageClassification) if is_flax_available() else ()

 __SCREAMING_SNAKE_CASE      							=       False
 __SCREAMING_SNAKE_CASE      							=       False
 __SCREAMING_SNAKE_CASE      							=       False




 def 						UpperCamelCase__							(self				)				->      Union[str, Any]:






  """simple docstring"""





  UpperCAmelCase__           =       FlaxResNetModelTester(self				)
  UpperCAmelCase__           =       ConfigTester(self , config_class=__SCREAMING_SNAKE_CASE , has_text_modality=__SCREAMING_SNAKE_CASE				)




 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  self.create_and_test_config_common_properties()
  self.config_tester.create_and_test_config_to_json_string()
  self.config_tester.create_and_test_config_to_json_file()
  self.config_tester.create_and_test_config_from_and_save_pretrained()
  self.config_tester.create_and_test_config_with_num_labels()
  self.config_tester.check_config_can_be_init_without_params()
  self.config_tester.check_config_arguments_init()




 def 						UpperCamelCase__							(self				)				->      Dict:






  """simple docstring"""





  return




 def 						UpperCamelCase__							(self				)				->      List[str]:






  """simple docstring"""





  UpperCAmelCase__           =       self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE				)




 def 						UpperCamelCase__							(self				)				->      Dict:






  """simple docstring"""





  UpperCAmelCase__           =       self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_for_image_classification(*__SCREAMING_SNAKE_CASE				)




 @unittest.skip(reason='ResNet does not use inputs_embeds'				)
 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  pass




 @unittest.skip(reason='ResNet does not support input and output embeddings'				)
 def 						UpperCamelCase__							(self				)				->      Any:






  """simple docstring"""





  pass




 def 						UpperCamelCase__							(self				)				->      Tuple:






  """simple docstring"""





  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.model_tester.prepare_config_and_inputs_for_common()

  for model_class in self.all_model_classes:
   UpperCAmelCase__           =       model_class(__SCREAMING_SNAKE_CASE				)
   UpperCAmelCase__           =       inspect.signature(model.__call__				)
   # signature.parameters is an OrderedDict => so arg_names order is deterministic
   UpperCAmelCase__           =       [*signature.parameters.keys()]

   UpperCAmelCase__           =       ['pixel_values']
   self.assertListEqual(arg_names[:1] , __SCREAMING_SNAKE_CASE				)




 def 						UpperCamelCase__							(self				)				->      List[Any]:






  """simple docstring"""





  def check_hidden_states_output(__a , __a , __a				):
   UpperCAmelCase__           =       model_class(__SCREAMING_SNAKE_CASE				)

   UpperCAmelCase__           =       model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE				)				)

   UpperCAmelCase__           =       outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

   UpperCAmelCase__           =       self.model_tester.num_stages
   self.assertEqual(len(__SCREAMING_SNAKE_CASE				) , expected_num_stages + 1				)




 @unittest.skip(reason='ResNet does not use feedforward chunking'				)
 def 						UpperCamelCase__							(self				)				->      Any:






  """simple docstring"""





  pass




 def 						UpperCamelCase__							(self				)				->      List[str]:






  """simple docstring"""





  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.model_tester.prepare_config_and_inputs_for_common()

  for model_class in self.all_model_classes:
   with self.subTest(model_class.__name__				):
    UpperCAmelCase__           =       self._prepare_for_class(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE				)
    UpperCAmelCase__           =       model_class(__SCREAMING_SNAKE_CASE				)

    @jax.jit
    def model_jitted(__a , **__a				):
     return model(pixel_values=__SCREAMING_SNAKE_CASE , **__SCREAMING_SNAKE_CASE				)

    with self.subTest('JIT Enabled'				):
     UpperCAmelCase__           =       model_jitted(**__SCREAMING_SNAKE_CASE				).to_tuple()

    with self.subTest('JIT Disabled'				):
     with jax.disable_jit():
      UpperCAmelCase__           =       model_jitted(**__SCREAMING_SNAKE_CASE				).to_tuple()

    self.assertEqual(len(__SCREAMING_SNAKE_CASE				) , len(__SCREAMING_SNAKE_CASE				)				)
    for jitted_output, output in zip(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE				):
     self.assertEqual(jitted_output.shape , output.shape				)







def 		UpperCamelCase_(    ) ->				List[str]:
 UpperCAmelCase__           =       Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'     )
 return image







@require_flax
class 					lowercase		( unittest.TestCase      ):



 '''simple docstring'''


 @cached_property
 def 						UpperCamelCase__							(self				)				->      Tuple:






  """simple docstring"""





  return AutoImageProcessor.from_pretrained('microsoft/resnet-50'				) if is_vision_available() else None




 @slow
 def 						UpperCamelCase__							(self				)				->      Union[str, Any]:






  """simple docstring"""





  UpperCAmelCase__           =       FlaxResNetForImageClassification.from_pretrained('microsoft/resnet-50'				)

  UpperCAmelCase__           =       self.default_image_processor
  UpperCAmelCase__           =       prepare_img()
  UpperCAmelCase__           =       image_processor(images=__SCREAMING_SNAKE_CASE , return_tensors='np'				)

  UpperCAmelCase__           =       model(**__SCREAMING_SNAKE_CASE				)

  # verify the logits
  UpperCAmelCase__           =       (1, 1000)
  self.assertEqual(outputs.logits.shape , __SCREAMING_SNAKE_CASE				)

  UpperCAmelCase__           =       jnp.array([-11.10_69, -9.78_77, -8.37_77]				)

  self.assertTrue(jnp.allclose(outputs.logits[0, :3] , __SCREAMING_SNAKE_CASE , atol=1E-4				)				)






import random
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():
 import PIL

 from transformers import FlavaImageProcessor
 from transformers.image_utils import PILImageResampling
 from transformers.models.flava.image_processing_flava import (
     FLAVA_CODEBOOK_MEAN,
     FLAVA_CODEBOOK_STD,
     FLAVA_IMAGE_MEAN,
     FLAVA_IMAGE_STD,
 )
else:
 _UpperCamelCase     =    _UpperCamelCase     =    _UpperCamelCase     =    _UpperCamelCase     =    None



class 					lowercase		( unittest.TestCase      ):



 '''simple docstring'''


 def __init__(self , __a , __a=7 , __a=3 , __a=30 , __a=400 , __a=True , __a=None , __a=True , __a=None , __a=None , __a=True , __a=1 / 255 , __a=True , __a=FLAVA_IMAGE_MEAN , __a=FLAVA_IMAGE_STD , __a=14 , __a=75 , __a=None , __a=16 , __a=0.3 , __a=None , __a=True , __a=None , __a=None , __a=True , __a=None , __a=True , __a=True , __a=FLAVA_CODEBOOK_MEAN , __a=FLAVA_CODEBOOK_STD , )				->      Optional[int]:






  """simple docstring"""





  UpperCAmelCase__           =       size if size is not None else {'height': 224, 'width': 224}
  UpperCAmelCase__           =       crop_size if crop_size is not None else {'height': 224, 'width': 224}
  UpperCAmelCase__           =       codebook_size if codebook_size is not None else {'height': 112, 'width': 112}
  UpperCAmelCase__           =       codebook_crop_size if codebook_crop_size is not None else {'height': 112, 'width': 112}

  UpperCAmelCase__           =       parent
  UpperCAmelCase__           =       batch_size
  UpperCAmelCase__           =       num_channels
  UpperCAmelCase__           =       do_resize
  UpperCAmelCase__           =       do_rescale
  UpperCAmelCase__           =       rescale_factor
  UpperCAmelCase__           =       min_resolution
  UpperCAmelCase__           =       max_resolution
  UpperCAmelCase__           =       size
  UpperCAmelCase__           =       resample if resample is not None else PILImageResampling.BICUBIC
  UpperCAmelCase__           =       do_normalize
  UpperCAmelCase__           =       image_mean
  UpperCAmelCase__           =       image_std
  UpperCAmelCase__           =       do_center_crop
  UpperCAmelCase__           =       crop_size

  UpperCAmelCase__           =       input_size_patches
  UpperCAmelCase__           =       total_mask_patches
  UpperCAmelCase__           =       mask_group_max_patches
  UpperCAmelCase__           =       mask_group_min_patches
  UpperCAmelCase__           =       mask_group_min_aspect_ratio
  UpperCAmelCase__           =       mask_group_max_aspect_ratio

  UpperCAmelCase__           =       codebook_do_resize
  UpperCAmelCase__           =       codebook_size
  UpperCAmelCase__           =       codebook_resample if codebook_resample is not None else PILImageResampling.LANCZOS
  UpperCAmelCase__           =       codebook_do_center_crop
  UpperCAmelCase__           =       codebook_crop_size
  UpperCAmelCase__           =       codebook_do_map_pixels
  UpperCAmelCase__           =       codebook_do_normalize
  UpperCAmelCase__           =       codebook_image_mean
  UpperCAmelCase__           =       codebook_image_std




 def 						UpperCamelCase__							(self				)				->      Any:






  """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,
      "resample": self.resample,
      "do_rescale": self.do_rescale,
      "rescale_factor": self.rescale_factor,
      "do_center_crop": self.do_center_crop,
      "crop_size": self.crop_size,
      "input_size_patches": self.input_size_patches,
      "total_mask_patches": self.total_mask_patches,
      "mask_group_max_patches": self.mask_group_max_patches,
      "mask_group_min_patches": self.mask_group_min_patches,
      "mask_group_min_aspect_ratio": self.mask_group_min_aspect_ratio,
      "mask_group_max_aspect_ratio": self.mask_group_min_aspect_ratio,
      "codebook_do_resize": self.codebook_do_resize,
      "codebook_size": self.codebook_size,
      "codebook_resample": self.codebook_resample,
      "codebook_do_center_crop": self.codebook_do_center_crop,
      "codebook_crop_size": self.codebook_crop_size,
      "codebook_do_map_pixels": self.codebook_do_map_pixels,
      "codebook_do_normalize": self.codebook_do_normalize,
      "codebook_image_mean": self.codebook_image_mean,
      "codebook_image_std": self.codebook_image_std,
  }




 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  return (self.size["height"], self.size["width"])




 def 						UpperCamelCase__							(self				)				->      Optional[Any]:






  """simple docstring"""





  return (
      (self.input_size_patches, self.input_size_patches)
      if not isinstance(self.input_size_patches , __a				)
      else self.input_size_patches
  )




 def 						UpperCamelCase__							(self				)				->      Optional[Any]:






  """simple docstring"""





  return (self.codebook_size["height"], self.codebook_size["width"])







@require_torch
@require_vision
class 					lowercase		( _UpperCamelCase				,       unittest.TestCase      ):



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE      							=       FlavaImageProcessor if is_vision_available() else None
 __SCREAMING_SNAKE_CASE      							=       None




 def 						UpperCamelCase__							(self				)				->      Tuple:






  """simple docstring"""





  UpperCAmelCase__           =       FlavaImageProcessingTester(self				)




 @property
 def 						UpperCamelCase__							(self				)				->      Dict:






  """simple docstring"""





  return self.image_processor_tester.prepare_image_processor_dict()




 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  UpperCAmelCase__           =       self.image_processing_class(**self.image_processor_dict				)
  self.assertTrue(hasattr(__a , 'image_mean'				)				)
  self.assertTrue(hasattr(__a , 'image_std'				)				)
  self.assertTrue(hasattr(__a , 'do_normalize'				)				)
  self.assertTrue(hasattr(__a , 'do_resize'				)				)
  self.assertTrue(hasattr(__a , 'resample'				)				)
  self.assertTrue(hasattr(__a , 'crop_size'				)				)
  self.assertTrue(hasattr(__a , 'do_center_crop'				)				)
  self.assertTrue(hasattr(__a , 'do_rescale'				)				)
  self.assertTrue(hasattr(__a , 'rescale_factor'				)				)
  self.assertTrue(hasattr(__a , 'masking_generator'				)				)
  self.assertTrue(hasattr(__a , 'codebook_do_resize'				)				)
  self.assertTrue(hasattr(__a , 'codebook_size'				)				)
  self.assertTrue(hasattr(__a , 'codebook_resample'				)				)
  self.assertTrue(hasattr(__a , 'codebook_do_center_crop'				)				)
  self.assertTrue(hasattr(__a , 'codebook_crop_size'				)				)
  self.assertTrue(hasattr(__a , 'codebook_do_map_pixels'				)				)
  self.assertTrue(hasattr(__a , 'codebook_do_normalize'				)				)
  self.assertTrue(hasattr(__a , 'codebook_image_mean'				)				)
  self.assertTrue(hasattr(__a , 'codebook_image_std'				)				)




 def 						UpperCamelCase__							(self				)				->      Tuple:






  """simple docstring"""





  UpperCAmelCase__           =       self.image_processing_class.from_dict(self.image_processor_dict				)
  self.assertEqual(image_processor.size , {'height': 224, 'width': 224}				)
  self.assertEqual(image_processor.crop_size , {'height': 224, 'width': 224}				)
  self.assertEqual(image_processor.codebook_size , {'height': 112, 'width': 112}				)
  self.assertEqual(image_processor.codebook_crop_size , {'height': 112, 'width': 112}				)

  UpperCAmelCase__           =       self.image_processing_class.from_dict(
      self.image_processor_dict , size=42 , crop_size=84 , codebook_size=33 , codebook_crop_size=66				)
  self.assertEqual(image_processor.size , {'height': 42, 'width': 42}				)
  self.assertEqual(image_processor.crop_size , {'height': 84, 'width': 84}				)
  self.assertEqual(image_processor.codebook_size , {'height': 33, 'width': 33}				)
  self.assertEqual(image_processor.codebook_crop_size , {'height': 66, 'width': 66}				)




 def 						UpperCamelCase__							(self				)				->      Any:






  """simple docstring"""





  pass




 def 						UpperCamelCase__							(self				)				->      List[Any]:






  """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=__a				)
  for image in image_inputs:
   self.assertIsInstance(__a , PIL.Image.Image				)

  # Test not batched input
  UpperCAmelCase__           =       image_processing(image_inputs[0] , return_tensors='pt'				)

  # Test no bool masked pos
  self.assertFalse('bool_masked_pos' in encoded_images				)

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()

  self.assertEqual(
      encoded_images.pixel_values.shape , (1, self.image_processor_tester.num_channels, expected_height, expected_width) , )

  # Test batched
  UpperCAmelCase__           =       image_processing(__a , return_tensors='pt'				)
  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()

  # Test no bool masked pos
  self.assertFalse('bool_masked_pos' in encoded_images				)

  self.assertEqual(
      encoded_images.pixel_values.shape , (
          self.image_processor_tester.batch_size,
          self.image_processor_tester.num_channels,
          expected_height,
          expected_width,
      ) , )




 def 						UpperCamelCase__							(self , __a , __a				)				->      Any:






  """simple docstring"""





  UpperCAmelCase__           =       self.image_processing_class(**self.image_processor_dict				)
  # create random tensors
  UpperCAmelCase__           =       prepare_image_inputs(self.image_processor_tester , equal_resolution=__a , **__a				)
  for image in image_inputs:
   self.assertIsInstance(__a , __a				)

  # Test not batched input
  UpperCAmelCase__           =       image_processing(image_inputs[0] , return_tensors='pt'				)

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()
  self.assertEqual(
      encoded_images.pixel_values.shape , (1, self.image_processor_tester.num_channels, expected_height, expected_width) , )

  UpperCAmelCase__           =       image_processing(__a , return_image_mask=__a , return_tensors='pt'				)

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()
  self.assertEqual(
      encoded_images.pixel_values.shape , (
          self.image_processor_tester.batch_size,
          self.image_processor_tester.num_channels,
          expected_height,
          expected_width,
      ) , )

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_mask_size()
  self.assertEqual(
      encoded_images.bool_masked_pos.shape , (
          self.image_processor_tester.batch_size,
          expected_height,
          expected_width,
      ) , )

  # Test batched
  UpperCAmelCase__           =       image_processing(__a , return_tensors='pt'				).pixel_values

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()
  self.assertEqual(
      encoded_images.shape , (
          self.image_processor_tester.batch_size,
          self.image_processor_tester.num_channels,
          expected_height,
          expected_width,
      ) , )

  # Test masking
  UpperCAmelCase__           =       image_processing(__a , return_image_mask=__a , return_tensors='pt'				)

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_image_size()
  self.assertEqual(
      encoded_images.pixel_values.shape , (
          self.image_processor_tester.batch_size,
          self.image_processor_tester.num_channels,
          expected_height,
          expected_width,
      ) , )

  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_mask_size()
  self.assertEqual(
      encoded_images.bool_masked_pos.shape , (
          self.image_processor_tester.batch_size,
          expected_height,
          expected_width,
      ) , )




 def 						UpperCamelCase__							(self				)				->      Dict:






  """simple docstring"""





  self._test_call_framework(np.ndarray , prepare_kwargs={'numpify': True}				)




 def 						UpperCamelCase__							(self				)				->      int:






  """simple docstring"""





  self._test_call_framework(torch.Tensor , prepare_kwargs={'torchify': True}				)




 def 						UpperCamelCase__							(self				)				->      Dict:






  """simple docstring"""





  random.seed(1234				)
  UpperCAmelCase__           =       self.image_processing_class(**self.image_processor_dict				)
  UpperCAmelCase__           =       prepare_image_inputs(self.image_processor_tester , equal_resolution=__a , torchify=__a				)

  # Test not batched input
  UpperCAmelCase__           =       image_processing(image_inputs[0] , return_image_mask=__a , return_tensors='pt'				)
  self.assertEqual(encoded_images.bool_masked_pos.sum().item() , 75				)




 def 						UpperCamelCase__							(self				)				->      Optional[int]:






  """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=__a				)
  for image in image_inputs:
   self.assertIsInstance(__a , PIL.Image.Image				)

  # Test not batched input
  UpperCAmelCase__           =       image_processing(image_inputs[0] , return_codebook_pixels=__a , return_tensors='pt'				)
  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_codebook_image_size()
  self.assertEqual(
      encoded_images.codebook_pixel_values.shape , (1, self.image_processor_tester.num_channels, expected_height, expected_width) , )

  # Test batched
  UpperCAmelCase__           =       image_processing(__a , return_codebook_pixels=__a , return_tensors='pt'				)
  UpperCAmelCase__       ,					UpperCAmelCase__           =       self.image_processor_tester.get_expected_codebook_image_size()
  self.assertEqual(
      encoded_images.codebook_pixel_values.shape , (
          self.image_processor_tester.batch_size,
          self.image_processor_tester.num_channels,
          expected_height,
          expected_width,
      ) , )



