'''simple docstring'''






import argparse
import os

import torch

from diffusers import (
    CMStochasticIterativeScheduler,
    ConsistencyModelPipeline,
    UNetaDModel,
)


SCREAMING_SNAKE_CASE_	   =			{
    'sample_size': 32,
    'in_channels': 3,
    'out_channels': 3,
    'layers_per_block': 2,
    'num_class_embeds': 10_00,
    'block_out_channels': [32, 64],
    'attention_head_dim': 8,
    'down_block_types': [
        'ResnetDownsampleBlock2D',
        'AttnDownBlock2D',
    ],
    'up_block_types': [
        'AttnUpBlock2D',
        'ResnetUpsampleBlock2D',
    ],
    'resnet_time_scale_shift': 'scale_shift',
    'upsample_type': 'resnet',
    'downsample_type': 'resnet',
}

SCREAMING_SNAKE_CASE_	   =			{
    'sample_size': 64,
    'in_channels': 3,
    'out_channels': 3,
    'layers_per_block': 3,
    'num_class_embeds': 10_00,
    'block_out_channels': [1_92, 1_92 * 2, 1_92 * 3, 1_92 * 4],
    'attention_head_dim': 64,
    'down_block_types': [
        'ResnetDownsampleBlock2D',
        'AttnDownBlock2D',
        'AttnDownBlock2D',
        'AttnDownBlock2D',
    ],
    'up_block_types': [
        'AttnUpBlock2D',
        'AttnUpBlock2D',
        'AttnUpBlock2D',
        'ResnetUpsampleBlock2D',
    ],
    'resnet_time_scale_shift': 'scale_shift',
    'upsample_type': 'resnet',
    'downsample_type': 'resnet',
}

SCREAMING_SNAKE_CASE_	   =			{
    'sample_size': 2_56,
    'in_channels': 3,
    'out_channels': 3,
    'layers_per_block': 2,
    'num_class_embeds': None,
    'block_out_channels': [2_56, 2_56, 2_56 * 2, 2_56 * 2, 2_56 * 4, 2_56 * 4],
    'attention_head_dim': 64,
    'down_block_types': [
        'ResnetDownsampleBlock2D',
        'ResnetDownsampleBlock2D',
        'ResnetDownsampleBlock2D',
        'AttnDownBlock2D',
        'AttnDownBlock2D',
        'AttnDownBlock2D',
    ],
    'up_block_types': [
        'AttnUpBlock2D',
        'AttnUpBlock2D',
        'AttnUpBlock2D',
        'ResnetUpsampleBlock2D',
        'ResnetUpsampleBlock2D',
        'ResnetUpsampleBlock2D',
    ],
    'resnet_time_scale_shift': 'default',
    'upsample_type': 'resnet',
    'downsample_type': 'resnet',
}

SCREAMING_SNAKE_CASE_	   =			{
    'num_train_timesteps': 40,
    'sigma_min': 0.002,
    'sigma_max': 80.0,
}

SCREAMING_SNAKE_CASE_	   =			{
    'num_train_timesteps': 2_01,
    'sigma_min': 0.002,
    'sigma_max': 80.0,
}

SCREAMING_SNAKE_CASE_	   =			{
    'num_train_timesteps': 1_51,
    'sigma_min': 0.002,
    'sigma_max': 80.0,
}






def  UpperCamelCase__					(					_lowercase    :				List[Any]     )							->	Optional[int]:
  if isinstance(_lowercase   ,    _lowercase     ):
    return v
  if v.lower() in ("yes", "true", "t", "y", "1"):
    return True
  elif v.lower() in ("no", "false", "f", "n", "0"):
    return False
  else:
    raise argparse.ArgumentTypeError("""boolean value expected"""     )






def  UpperCamelCase__					(					_lowercase    :				Any   ,    _lowercase    :				Optional[int]   ,    _lowercase    :				Tuple   ,    _lowercase    :				List[Any]   ,    _lowercase    :				int=False     )							->	List[Any]:
  __UpperCAmelCase:					List[str]		= checkpoint[F'''{old_prefix}.in_layers.0.weight''']
  __UpperCAmelCase:					List[str]		= checkpoint[F'''{old_prefix}.in_layers.0.bias''']
  __UpperCAmelCase:					List[Any]		= checkpoint[F'''{old_prefix}.in_layers.2.weight''']
  __UpperCAmelCase:					Optional[Any]		= checkpoint[F'''{old_prefix}.in_layers.2.bias''']
  __UpperCAmelCase:					Dict		= checkpoint[F'''{old_prefix}.emb_layers.1.weight''']
  __UpperCAmelCase:					str		= checkpoint[F'''{old_prefix}.emb_layers.1.bias''']
  __UpperCAmelCase:					List[Any]		= checkpoint[F'''{old_prefix}.out_layers.0.weight''']
  __UpperCAmelCase:					Tuple		= checkpoint[F'''{old_prefix}.out_layers.0.bias''']
  __UpperCAmelCase:					List[Any]		= checkpoint[F'''{old_prefix}.out_layers.3.weight''']
  __UpperCAmelCase:					List[str]		= checkpoint[F'''{old_prefix}.out_layers.3.bias''']

  if has_skip:
    __UpperCAmelCase:					List[Any]		= checkpoint[F'''{old_prefix}.skip_connection.weight''']
    __UpperCAmelCase:					Optional[Any]		= checkpoint[F'''{old_prefix}.skip_connection.bias''']

  return new_checkpoint






def  UpperCamelCase__					(					_lowercase    :				Optional[Any]   ,    _lowercase    :				List[str]   ,    _lowercase    :				Optional[Any]   ,    _lowercase    :				Tuple   ,    _lowercase    :				List[str]=None     )							->	int:
  __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase:					Optional[Any]		= checkpoint[F'''{old_prefix}.qkv.weight'''].chunk(3   ,    dim=0     )
  __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase:					Optional[int]		= checkpoint[F'''{old_prefix}.qkv.bias'''].chunk(3   ,    dim=0     )

  __UpperCAmelCase:					List[Any]		= checkpoint[F'''{old_prefix}.norm.weight''']
  __UpperCAmelCase:					Dict		= checkpoint[F'''{old_prefix}.norm.bias''']

  __UpperCAmelCase:					Optional[int]		= weight_q.squeeze(-1     ).squeeze(-1     )
  __UpperCAmelCase:					Any		= bias_q.squeeze(-1     ).squeeze(-1     )
  __UpperCAmelCase:					List[str]		= weight_k.squeeze(-1     ).squeeze(-1     )
  __UpperCAmelCase:					Dict		= bias_k.squeeze(-1     ).squeeze(-1     )
  __UpperCAmelCase:					Optional[Any]		= weight_v.squeeze(-1     ).squeeze(-1     )
  __UpperCAmelCase:					Dict		= bias_v.squeeze(-1     ).squeeze(-1     )

  __UpperCAmelCase:					Optional[int]		= (
      checkpoint[F'''{old_prefix}.proj_out.weight'''].squeeze(-1     ).squeeze(-1     )
  )
  __UpperCAmelCase:					Dict		= checkpoint[F'''{old_prefix}.proj_out.bias'''].squeeze(-1     ).squeeze(-1     )

  return new_checkpoint






def  UpperCamelCase__					(					_lowercase    :				str   ,    _lowercase    :				Any     )							->	str:
  __UpperCAmelCase:					List[str]		= torch.load(_lowercase   ,    map_location="""cpu"""     )
  __UpperCAmelCase:					List[str]		= {}

  __UpperCAmelCase:					str		= checkpoint["""time_embed.0.weight"""]
  __UpperCAmelCase:					Any		= checkpoint["""time_embed.0.bias"""]
  __UpperCAmelCase:					Any		= checkpoint["""time_embed.2.weight"""]
  __UpperCAmelCase:					Optional[int]		= checkpoint["""time_embed.2.bias"""]

  if unet_config["num_class_embeds"] is not None:
    __UpperCAmelCase:					Dict		= checkpoint["""label_emb.weight"""]

  __UpperCAmelCase:					int		= checkpoint["""input_blocks.0.0.weight"""]
  __UpperCAmelCase:					int		= checkpoint["""input_blocks.0.0.bias"""]

  __UpperCAmelCase:					Optional[int]		= unet_config["""down_block_types"""]
  __UpperCAmelCase:					List[Any]		= unet_config["""layers_per_block"""]
  __UpperCAmelCase:					Union[str, Any]		= unet_config["""attention_head_dim"""]
  __UpperCAmelCase:					Any		= unet_config["""block_out_channels"""]
  __UpperCAmelCase:					Optional[int]		= 1
  __UpperCAmelCase:					int		= channels_list[0]

  for i, layer_type in enumerate(_lowercase     ):
    __UpperCAmelCase:					Optional[Any]		= channels_list[i]
    __UpperCAmelCase:					int		= current_channels != prev_channels
    if layer_type == "ResnetDownsampleBlock2D":
      for j in range(_lowercase     ):
        __UpperCAmelCase:					Dict		= F'''down_blocks.{i}.resnets.{j}'''
        __UpperCAmelCase:					Optional[Any]		= F'''input_blocks.{current_layer}.0'''
        __UpperCAmelCase:					Any		= True if j == 0 and downsample_block_has_skip else False
        __UpperCAmelCase:					Dict		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    has_skip=_lowercase     )
        current_layer += 1

    elif layer_type == "AttnDownBlock2D":
      for j in range(_lowercase     ):
        __UpperCAmelCase:					Union[str, Any]		= F'''down_blocks.{i}.resnets.{j}'''
        __UpperCAmelCase:					int		= F'''input_blocks.{current_layer}.0'''
        __UpperCAmelCase:					Dict		= True if j == 0 and downsample_block_has_skip else False
        __UpperCAmelCase:					str		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    has_skip=_lowercase     )
        __UpperCAmelCase:					int		= F'''down_blocks.{i}.attentions.{j}'''
        __UpperCAmelCase:					Dict		= F'''input_blocks.{current_layer}.1'''
        __UpperCAmelCase:					Any		= convert_attention(
            _lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
        current_layer += 1

    if i != len(_lowercase     ) - 1:
      __UpperCAmelCase:					str		= F'''down_blocks.{i}.downsamplers.0'''
      __UpperCAmelCase:					Dict		= F'''input_blocks.{current_layer}.0'''
      __UpperCAmelCase:					str		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
      current_layer += 1

    __UpperCAmelCase:					List[str]		= current_channels

  # hardcoded the mid-block for now
  __UpperCAmelCase:					List[str]		= """mid_block.resnets.0"""
  __UpperCAmelCase:					Dict		= """middle_block.0"""
  __UpperCAmelCase:					Optional[Any]		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
  __UpperCAmelCase:					Dict		= """mid_block.attentions.0"""
  __UpperCAmelCase:					str		= """middle_block.1"""
  __UpperCAmelCase:					Union[str, Any]		= convert_attention(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
  __UpperCAmelCase:					Optional[Any]		= """mid_block.resnets.1"""
  __UpperCAmelCase:					Any		= """middle_block.2"""
  __UpperCAmelCase:					int		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )

  __UpperCAmelCase:					Any		= 0
  __UpperCAmelCase:					Dict		= unet_config["""up_block_types"""]

  for i, layer_type in enumerate(_lowercase     ):
    if layer_type == "ResnetUpsampleBlock2D":
      for j in range(layers_per_block + 1     ):
        __UpperCAmelCase:					List[str]		= F'''up_blocks.{i}.resnets.{j}'''
        __UpperCAmelCase:					Any		= F'''output_blocks.{current_layer}.0'''
        __UpperCAmelCase:					Optional[Any]		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    has_skip=_lowercase     )
        current_layer += 1

      if i != len(_lowercase     ) - 1:
        __UpperCAmelCase:					Dict		= F'''up_blocks.{i}.upsamplers.0'''
        __UpperCAmelCase:					Tuple		= F'''output_blocks.{current_layer-1}.1'''
        __UpperCAmelCase:					Tuple		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
    elif layer_type == "AttnUpBlock2D":
      for j in range(layers_per_block + 1     ):
        __UpperCAmelCase:					Dict		= F'''up_blocks.{i}.resnets.{j}'''
        __UpperCAmelCase:					Any		= F'''output_blocks.{current_layer}.0'''
        __UpperCAmelCase:					Tuple		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    has_skip=_lowercase     )
        __UpperCAmelCase:					List[Any]		= F'''up_blocks.{i}.attentions.{j}'''
        __UpperCAmelCase:					List[Any]		= F'''output_blocks.{current_layer}.1'''
        __UpperCAmelCase:					int		= convert_attention(
            _lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
        current_layer += 1

      if i != len(_lowercase     ) - 1:
        __UpperCAmelCase:					List[Any]		= F'''up_blocks.{i}.upsamplers.0'''
        __UpperCAmelCase:					Tuple		= F'''output_blocks.{current_layer-1}.2'''
        __UpperCAmelCase:					Union[str, Any]		= convert_resnet(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )

  __UpperCAmelCase:					List[Any]		= checkpoint["""out.0.weight"""]
  __UpperCAmelCase:					Optional[Any]		= checkpoint["""out.0.bias"""]
  __UpperCAmelCase:					Union[str, Any]		= checkpoint["""out.2.weight"""]
  __UpperCAmelCase:					Any		= checkpoint["""out.2.bias"""]

  return new_checkpoint


if __name__ == "__main__":
    SCREAMING_SNAKE_CASE_	   =			argparse.ArgumentParser()

    parser.add_argument('--unet_path', default=None, type=str, required=True, help='Path to the unet.pt to convert.')
    parser.add_argument(
        '--dump_path', default=None, type=str, required=True, help='Path to output the converted UNet model.'
    )
    parser.add_argument('--class_cond', default=True, type=str, help='Whether the model is class-conditional.')

    SCREAMING_SNAKE_CASE_	   =			parser.parse_args()
    SCREAMING_SNAKE_CASE_	   =			strabool(args.class_cond)

    SCREAMING_SNAKE_CASE_	   =			os.path.basename(args.unet_path)
    print(F"""Checkpoint: {ckpt_name}""")

    # Get U-Net config
    if "imagenet64" in ckpt_name:
        SCREAMING_SNAKE_CASE_	   =			IMAGENET_64_UNET_CONFIG
    elif "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)):
        SCREAMING_SNAKE_CASE_	   =			LSUN_256_UNET_CONFIG
    elif "test" in ckpt_name:
        SCREAMING_SNAKE_CASE_	   =			TEST_UNET_CONFIG
    else:
        raise ValueError(F"""Checkpoint type {ckpt_name} is not currently supported.""")

    if not args.class_cond:
        SCREAMING_SNAKE_CASE_	   =			None

    SCREAMING_SNAKE_CASE_	   =			con_pt_to_diffuser(args.unet_path, unet_config)

    SCREAMING_SNAKE_CASE_	   =			UNetaDModel(**unet_config)
    image_unet.load_state_dict(converted_unet_ckpt)

    # Get scheduler config
    if "cd" in ckpt_name or "test" in ckpt_name:
        SCREAMING_SNAKE_CASE_	   =			CD_SCHEDULER_CONFIG
    elif "ct" in ckpt_name and "imagenet64" in ckpt_name:
        SCREAMING_SNAKE_CASE_	   =			CT_IMAGENET_64_SCHEDULER_CONFIG
    elif "ct" in ckpt_name and "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)):
        SCREAMING_SNAKE_CASE_	   =			CT_LSUN_256_SCHEDULER_CONFIG
    else:
        raise ValueError(F"""Checkpoint type {ckpt_name} is not currently supported.""")

    SCREAMING_SNAKE_CASE_	   =			CMStochasticIterativeScheduler(**scheduler_config)

    SCREAMING_SNAKE_CASE_	   =			ConsistencyModelPipeline(unet=image_unet, scheduler=cm_scheduler)
    consistency_model.save_pretrained(args.dump_path)
'''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 PoolFormerImageProcessor




class    a (       unittest.TestCase				):



  """simple docstring"""







  def __init__(							self   ,    snake_case_   ,    snake_case_=7   ,    snake_case_=3   ,    snake_case_=30   ,    snake_case_=400   ,    snake_case_=True   ,    snake_case_=None   ,    snake_case_=0.9   ,    snake_case_=None   ,    snake_case_=True   ,    snake_case_=[0.5, 0.5, 0.5]   ,    snake_case_=[0.5, 0.5, 0.5]   ,    ):

    '''simple docstring'''







    __UpperCAmelCase:					List[Any]		= size if size is not None else {"""shortest_edge""": 30}
    __UpperCAmelCase:					str		= crop_size if crop_size is not None else {"""height""": 30, """width""": 30}
    __UpperCAmelCase:					Dict		= parent
    __UpperCAmelCase:					Union[str, Any]		= batch_size
    __UpperCAmelCase:					List[Any]		= num_channels
    __UpperCAmelCase:					List[str]		= min_resolution
    __UpperCAmelCase:					List[str]		= max_resolution
    __UpperCAmelCase:					Tuple		= do_resize_and_center_crop
    __UpperCAmelCase:					Union[str, Any]		= size
    __UpperCAmelCase:					str		= crop_pct
    __UpperCAmelCase:					List[Any]		= crop_size
    __UpperCAmelCase:					str		= do_normalize
    __UpperCAmelCase:					Union[str, Any]		= image_mean
    __UpperCAmelCase:					List[str]		= image_std







  def    lowercase_  (							self					):

    '''simple docstring'''







    return {
        "size": self.size,
        "do_resize_and_center_crop": self.do_resize_and_center_crop,
        "crop_pct": self.crop_pct,
        "crop_size": self.crop_size,
        "do_normalize": self.do_normalize,
        "image_mean": self.image_mean,
        "image_std": self.image_std,
    }




@require_torch
@require_vision
class    a (       __lowerCAmelCase						,  unittest.TestCase				):



  """simple docstring"""
  __lowerCAmelCase				      =					PoolFormerImageProcessor if is_vision_available() else None







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Any		= PoolFormerImageProcessingTester(self					)







  @property
  def    lowercase_  (							self					):

    '''simple docstring'''







    return self.image_processor_tester.prepare_image_processor_dict()







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Optional[Any]		= self.image_processing_class(**self.image_processor_dict					)
    self.assertTrue(hasattr(snake_case_   ,    """do_resize_and_center_crop"""					)					)
    self.assertTrue(hasattr(snake_case_   ,    """size"""					)					)
    self.assertTrue(hasattr(snake_case_   ,    """crop_pct"""					)					)
    self.assertTrue(hasattr(snake_case_   ,    """do_normalize"""					)					)
    self.assertTrue(hasattr(snake_case_   ,    """image_mean"""					)					)
    self.assertTrue(hasattr(snake_case_   ,    """image_std"""					)					)







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					List[str]		= self.image_processing_class.from_dict(self.image_processor_dict					)
    self.assertEqual(image_processor.size   ,    {"""shortest_edge""": 30}					)
    self.assertEqual(image_processor.crop_size   ,    {"""height""": 30, """width""": 30}					)

    __UpperCAmelCase:					Dict		= self.image_processing_class.from_dict(self.image_processor_dict   ,    size=42   ,    crop_size=84					)
    self.assertEqual(image_processor.size   ,    {"""shortest_edge""": 42}					)
    self.assertEqual(image_processor.crop_size   ,    {"""height""": 84, """width""": 84}					)







  def    lowercase_  (							self					):

    '''simple docstring'''







    pass







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Any		= self.image_processing_class(**self.image_processor_dict					)
    # create random PIL images
    __UpperCAmelCase:					Optional[Any]		= prepare_image_inputs(self.image_processor_tester   ,    equal_resolution=snake_case_					)
    for image in image_inputs:
      self.assertIsInstance(snake_case_   ,    Image.Image					)

    # Test not batched input
    __UpperCAmelCase:					Optional[int]		= 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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )

    # Test batched
    __UpperCAmelCase:					Any		= image_processing(snake_case_   ,    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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Optional[Any]		= self.image_processing_class(**self.image_processor_dict					)
    # create random numpy tensors
    __UpperCAmelCase:					Union[str, Any]		= prepare_image_inputs(self.image_processor_tester   ,    equal_resolution=snake_case_   ,    numpify=snake_case_					)
    for image in image_inputs:
      self.assertIsInstance(snake_case_   ,    np.ndarray					)

    # Test not batched input
    __UpperCAmelCase:					Union[str, Any]		= 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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )

    # Test batched
    __UpperCAmelCase:					str		= image_processing(snake_case_   ,    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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Any		= self.image_processing_class(**self.image_processor_dict					)
    # create random PyTorch tensors
    __UpperCAmelCase:					Dict		= prepare_image_inputs(self.image_processor_tester   ,    equal_resolution=snake_case_   ,    torchify=snake_case_					)
    for image in image_inputs:
      self.assertIsInstance(snake_case_   ,    torch.Tensor					)

    # Test not batched input
    __UpperCAmelCase:					Optional[int]		= 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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )

    # Test batched
    __UpperCAmelCase:					Optional[int]		= image_processing(snake_case_   ,    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.crop_size["""height"""],
            self.image_processor_tester.crop_size["""width"""],
        )   ,    )