


"""simple docstring"""




import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image

from diffusers import (
    DDIMScheduler,
    KandinskyVaaControlnetImgaImgPipeline,
    KandinskyVaaPriorEmbaEmbPipeline,
    UNetaDConditionModel,
    VQModel,
)
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference


enable_full_determinism()




class 			__snake_case   (lowerCamelCase			,		unittest.TestCase  ):
							__a					 =       KandinskyVaaControlnetImgaImgPipeline
							__a					 =       ['''image_embeds''', '''negative_image_embeds''', '''image''', '''hint''']
							__a					 =       ['''image_embeds''', '''negative_image_embeds''', '''image''', '''hint''']
							__a					 =       [
							    '''generator''',
							    '''height''',
							    '''width''',
							    '''strength''',
							    '''guidance_scale''',
							    '''num_inference_steps''',
							    '''return_dict''',
							    '''guidance_scale''',
							    '''num_images_per_prompt''',
							    '''output_type''',
							    '''return_dict''',
							]
							__a					 =       False




							@property
							def   __a   (     self:    Union[str, Any]   ):
										return 32




							@property
							def   __a   (     self:    Tuple   ):
										return 32




							@property
							def   __a   (     self:    Any   ):
										return self.time_input_dim




							@property
							def   __a   (     self:    int   ):
										return self.time_input_dim * 4




							@property
							def   __a   (     self:    int   ):
										return 1_00




							@property
							def   __a   (     self:    Optional[Any]   ):
										torch.manual_seed(0   )

										__lowerCamelCase          =      {
										    """in_channels""": 8,
										    # Out channels is double in channels because predicts mean and variance
										    """out_channels""": 8,
										    """addition_embed_type""": """image_hint""",
										    """down_block_types""": ("""ResnetDownsampleBlock2D""", """SimpleCrossAttnDownBlock2D"""),
										    """up_block_types""": ("""SimpleCrossAttnUpBlock2D""", """ResnetUpsampleBlock2D"""),
										    """mid_block_type""": """UNetMidBlock2DSimpleCrossAttn""",
										    """block_out_channels""": (self.block_out_channels_a, self.block_out_channels_a * 2),
										    """layers_per_block""": 1,
										    """encoder_hid_dim""": self.text_embedder_hidden_size,
										    """encoder_hid_dim_type""": """image_proj""",
										    """cross_attention_dim""": self.cross_attention_dim,
										    """attention_head_dim""": 4,
										    """resnet_time_scale_shift""": """scale_shift""",
										    """class_embed_type""": None,
										}

										__lowerCamelCase          =      UNetaDConditionModel(**A_   )
										return model




							@property
							def   __a   (     self:    Optional[Any]   ):
										return {
										    "block_out_channels": [32, 32, 64, 64],
										    "down_block_types": [
										        "DownEncoderBlock2D",
										        "DownEncoderBlock2D",
										        "DownEncoderBlock2D",
										        "AttnDownEncoderBlock2D",
										    ],
										    "in_channels": 3,
										    "latent_channels": 4,
										    "layers_per_block": 1,
										    "norm_num_groups": 8,
										    "norm_type": "spatial",
										    "num_vq_embeddings": 12,
										    "out_channels": 3,
										    "up_block_types": ["AttnUpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D"],
										    "vq_embed_dim": 4,
										}




							@property
							def   __a   (     self:    int   ):
										torch.manual_seed(0   )
										__lowerCamelCase          =      VQModel(**self.dummy_movq_kwargs   )
										return model




							def   __a   (     self:    List[str]   ):
										__lowerCamelCase          =      self.dummy_unet
										__lowerCamelCase          =      self.dummy_movq

										__lowerCamelCase          =      {
										    """num_train_timesteps""": 10_00,
										    """beta_schedule""": """linear""",
										    """beta_start""": 0.00_085,
										    """beta_end""": 0.012,
										    """clip_sample""": False,
										    """set_alpha_to_one""": False,
										    """steps_offset""": 0,
										    """prediction_type""": """epsilon""",
										    """thresholding""": False,
										}

										__lowerCamelCase          =      DDIMScheduler(**A_   )

										__lowerCamelCase          =      {
										    """unet""": unet,
										    """scheduler""": scheduler,
										    """movq""": movq,
										}

										return components




							def   __a   (     self:    Tuple     ,							A_:    Union[str, Any]     ,							A_:    Tuple=0   ):
										__lowerCamelCase          =      floats_tensor((1, self.text_embedder_hidden_size)     ,							rng=random.Random(A_   )   ).to(A_   )
										__lowerCamelCase          =      floats_tensor((1, self.text_embedder_hidden_size)     ,							rng=random.Random(seed + 1   )   ).to(
										    A_   )
										# create init_image
										__lowerCamelCase          =      floats_tensor((1, 3, 64, 64)     ,							rng=random.Random(A_   )   ).to(A_   )
										__lowerCamelCase          =      image.cpu().permute(0     ,							2     ,							3     ,							1   )[0]
										__lowerCamelCase          =      Image.fromarray(np.uinta(A_   )   ).convert("""RGB"""   ).resize((2_56, 2_56)   )
										# create hint
										__lowerCamelCase          =      floats_tensor((1, 3, 64, 64)     ,							rng=random.Random(A_   )   ).to(A_   )

										if str(A_   ).startswith("""mps"""   ):
													__lowerCamelCase          =      torch.manual_seed(A_   )
										else:
													__lowerCamelCase          =      torch.Generator(device=A_   ).manual_seed(A_   )
										__lowerCamelCase          =      {
										    """image""": init_image,
										    """image_embeds""": image_embeds,
										    """negative_image_embeds""": negative_image_embeds,
										    """hint""": hint,
										    """generator""": generator,
										    """height""": 64,
										    """width""": 64,
										    """num_inference_steps""": 10,
										    """guidance_scale""": 7.0,
										    """strength""": 0.2,
										    """output_type""": """np""",
										}
										return inputs




							def   __a   (     self:    List[str]   ):
										__lowerCamelCase          =      """cpu"""

										__lowerCamelCase          =      self.get_dummy_components()

										__lowerCamelCase          =      self.pipeline_class(**A_   )
										__lowerCamelCase          =      pipe.to(A_   )

										pipe.set_progress_bar_config(disable=A_   )

										__lowerCamelCase          =      pipe(**self.get_dummy_inputs(A_   )   )
										__lowerCamelCase          =      output.images

										__lowerCamelCase          =      pipe(
										    **self.get_dummy_inputs(A_   )     ,							return_dict=A_     ,							)[0]

										__lowerCamelCase          =      image[0, -3:, -3:, -1]
										__lowerCamelCase          =      image_from_tuple[0, -3:, -3:, -1]

										assert image.shape == (1, 64, 64, 3)

										__lowerCamelCase          =      np.array(
										    [0.54_985_034, 0.55_509_365, 0.52_561_504, 0.5_570_494, 0.5_593_818, 0.5_263_979, 0.50_285_643, 0.5_069_846, 0.51_196_736]   )
										assert (
										    np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-2
										), f' expected_slice {expected_slice}, but got {image_slice.flatten()}'
										assert (
										    np.abs(image_from_tuple_slice.flatten() - expected_slice   ).max() < 1E-2
										), f' expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}'




@slow
@require_torch_gpu
class 			__snake_case   (unittest.TestCase  ):




							def   __a   (     self:    Optional[Any]   ):
										# clean up the VRAM after each test
										super().tearDown()
										gc.collect()
										torch.cuda.empty_cache()




							def   __a   (     self:    Tuple   ):
										__lowerCamelCase          =      load_numpy(
										    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
										    """/kandinskyv22/kandinskyv22_controlnet_img2img_robotcat_fp16.npy"""   )

										__lowerCamelCase          =      load_image(
										    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main""" """/kandinsky/cat.png"""   )
										__lowerCamelCase          =      init_image.resize((5_12, 5_12)   )

										__lowerCamelCase          =      load_image(
										    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
										    """/kandinskyv22/hint_image_cat.png"""   )
										__lowerCamelCase          =      torch.from_numpy(np.array(A_   )   ).float() / 255.0
										__lowerCamelCase          =      hint.permute(2     ,							0     ,							1   ).unsqueeze(0   )

										__lowerCamelCase          =      """A robot, 4k photo"""

										__lowerCamelCase          =      KandinskyVaaPriorEmbaEmbPipeline.from_pretrained(
										    """kandinsky-community/kandinsky-2-2-prior"""     ,							torch_dtype=torch.floataa   )
										pipe_prior.to(A_   )

										__lowerCamelCase          =      KandinskyVaaControlnetImgaImgPipeline.from_pretrained(
										    """kandinsky-community/kandinsky-2-2-controlnet-depth"""     ,							torch_dtype=torch.floataa   )
										__lowerCamelCase          =      pipeline.to(A_   )

										pipeline.set_progress_bar_config(disable=A_   )

										__lowerCamelCase          =      torch.Generator(device="""cpu"""   ).manual_seed(0   )

										__lowerCamelCase     ,__lowerCamelCase          =      pipe_prior(
										    A_     ,							image=A_     ,							strength=0.85     ,							generator=A_     ,							negative_prompt=""""""     ,							).to_tuple()

										__lowerCamelCase          =      pipeline(
										    image=A_     ,							image_embeds=A_     ,							negative_image_embeds=A_     ,							hint=A_     ,							generator=A_     ,							num_inference_steps=1_00     ,							height=5_12     ,							width=5_12     ,							strength=0.5     ,							output_type="""np"""     ,							)

										__lowerCamelCase          =      output.images[0]

										assert image.shape == (5_12, 5_12, 3)

										assert_mean_pixel_difference(A_     ,							A_   )








"""simple docstring"""




import json
import pathlib
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision, slow
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 DetaImageProcessor




class 			__snake_case   (unittest.TestCase  ):




							def __init__(     self:    Any     ,							A_:    Optional[int]     ,							A_:    Any=7     ,							A_:    Union[str, Any]=3     ,							A_:    List[Any]=30     ,							A_:    int=4_00     ,							A_:    Any=True     ,							A_:    str=None     ,							A_:    Dict=True     ,							A_:    Optional[Any]=[0.5, 0.5, 0.5]     ,							A_:    List[Any]=[0.5, 0.5, 0.5]     ,							A_:    Any=True     ,							A_:    Optional[Any]=1 / 2_55     ,							A_:    int=True     ,							):
										# by setting size["longest_edge"] > max_resolution we're effectively not testing this :p
										__lowerCamelCase          =      size if size is not None else {"""shortest_edge""": 18, """longest_edge""": 13_33}
										__lowerCamelCase          =      parent
										__lowerCamelCase          =      batch_size
										__lowerCamelCase          =      num_channels
										__lowerCamelCase          =      min_resolution
										__lowerCamelCase          =      max_resolution
										__lowerCamelCase          =      do_resize
										__lowerCamelCase          =      size
										__lowerCamelCase          =      do_normalize
										__lowerCamelCase          =      image_mean
										__lowerCamelCase          =      image_std
										__lowerCamelCase          =      do_rescale
										__lowerCamelCase          =      rescale_factor
										__lowerCamelCase          =      do_pad




							def   __a   (     self:    Tuple   ):
										return {
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "do_normalize": self.do_normalize,
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_rescale": self.do_rescale,
										    "rescale_factor": self.rescale_factor,
										    "do_pad": self.do_pad,
										}




							def   __a   (     self:    int     ,							A_:    List[str]     ,							A_:    List[Any]=False   ):
										if not batched:
													__lowerCamelCase          =      image_inputs[0]
													if isinstance(A_     ,							Image.Image   ):
																__lowerCamelCase     ,__lowerCamelCase          =      image.size
													else:
																__lowerCamelCase     ,__lowerCamelCase          =      image.shape[1], image.shape[2]
													if w < h:
																__lowerCamelCase          =      int(self.size["""shortest_edge"""] * h / w   )
																__lowerCamelCase          =      self.size["""shortest_edge"""]
													elif w > h:
																__lowerCamelCase          =      self.size["""shortest_edge"""]
																__lowerCamelCase          =      int(self.size["""shortest_edge"""] * w / h   )
													else:
																__lowerCamelCase          =      self.size["""shortest_edge"""]
																__lowerCamelCase          =      self.size["""shortest_edge"""]

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

										return expected_height, expected_width




@require_torch
@require_vision
class 			__snake_case   (lowerCamelCase			,		unittest.TestCase  ):
							__a					 =       DetaImageProcessor if is_vision_available() else None




							def   __a   (     self:    Tuple   ):
										__lowerCamelCase          =      DetaImageProcessingTester(self   )




							@property
							def   __a   (     self:    Optional[int]   ):
										return self.image_processor_tester.prepare_image_processor_dict()




							def   __a   (     self:    Tuple   ):
										__lowerCamelCase          =      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_     ,							"""do_rescale"""   )   )
										self.assertTrue(hasattr(A_     ,							"""do_pad"""   )   )
										self.assertTrue(hasattr(A_     ,							"""size"""   )   )




							def   __a   (     self:    List[Any]   ):
										__lowerCamelCase          =      self.image_processing_class.from_dict(self.image_processor_dict   )
										self.assertEqual(image_processor.size     ,							{"""shortest_edge""": 18, """longest_edge""": 13_33}   )
										self.assertEqual(image_processor.do_pad     ,							A_   )




							def   __a   (     self:    Any   ):
										pass




							def   __a   (     self:    Optional[Any]   ):
										# Initialize image_processing
										__lowerCamelCase          =      self.image_processing_class(**self.image_processor_dict   )
										# create random PIL images
										__lowerCamelCase          =      prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=A_   )
										for image in image_inputs:
													self.assertIsInstance(A_     ,							Image.Image   )

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

										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_   )

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

										# Test batched
										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_     ,							batched=A_   )

										__lowerCamelCase          =      image_processing(A_     ,							return_tensors="""pt"""   ).pixel_values
										self.assertEqual(
										    encoded_images.shape     ,							(
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )     ,							)




							def   __a   (     self:    int   ):
										# Initialize image_processing
										__lowerCamelCase          =      self.image_processing_class(**self.image_processor_dict   )
										# create random numpy tensors
										__lowerCamelCase          =      prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=A_     ,							numpify=A_   )
										for image in image_inputs:
													self.assertIsInstance(A_     ,							np.ndarray   )

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

										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_   )

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

										# Test batched
										__lowerCamelCase          =      image_processing(A_     ,							return_tensors="""pt"""   ).pixel_values

										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_     ,							batched=A_   )

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




							def   __a   (     self:    Dict   ):
										# Initialize image_processing
										__lowerCamelCase          =      self.image_processing_class(**self.image_processor_dict   )
										# create random PyTorch tensors
										__lowerCamelCase          =      prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=A_     ,							torchify=A_   )
										for image in image_inputs:
													self.assertIsInstance(A_     ,							torch.Tensor   )

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

										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_   )

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

										# Test batched
										__lowerCamelCase          =      image_processing(A_     ,							return_tensors="""pt"""   ).pixel_values

										__lowerCamelCase     ,__lowerCamelCase          =      self.image_processor_tester.get_expected_values(A_     ,							batched=A_   )

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




							@slow
							def   __a   (     self:    List[str]   ):
										# prepare image and target
										__lowerCamelCase          =      Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""   )
										with open("""./tests/fixtures/tests_samples/COCO/coco_annotations.txt"""     ,							"""r"""   ) as f:
													__lowerCamelCase          =      json.loads(f.read()   )

										__lowerCamelCase          =      {"""image_id""": 3_97_69, """annotations""": target}

										# encode them
										__lowerCamelCase          =      DetaImageProcessor()
										__lowerCamelCase          =      image_processing(images=A_     ,							annotations=A_     ,							return_tensors="""pt"""   )

										# verify pixel values
										__lowerCamelCase          =      torch.Size([1, 3, 8_00, 10_66]   )
										self.assertEqual(encoding["""pixel_values"""].shape     ,							A_   )

										__lowerCamelCase          =      torch.tensor([0.2_796, 0.3_138, 0.3_481]   )
										self.assertTrue(torch.allclose(encoding["""pixel_values"""][0, 0, 0, :3]     ,							A_     ,							atol=1E-4   )   )

										# verify area
										__lowerCamelCase          =      torch.tensor([5_887.9_600, 11_250.2_061, 489_353.8_438, 837_122.7_500, 147_967.5_156, 165_732.3_438]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""area"""]     ,							A_   )   )
										# verify boxes
										__lowerCamelCase          =      torch.Size([6, 4]   )
										self.assertEqual(encoding["""labels"""][0]["""boxes"""].shape     ,							A_   )
										__lowerCamelCase          =      torch.tensor([0.5_503, 0.2_765, 0.0_604, 0.2_215]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""boxes"""][0]     ,							A_     ,							atol=1E-3   )   )
										# verify image_id
										__lowerCamelCase          =      torch.tensor([3_97_69]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""image_id"""]     ,							A_   )   )
										# verify is_crowd
										__lowerCamelCase          =      torch.tensor([0, 0, 0, 0, 0, 0]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""iscrowd"""]     ,							A_   )   )
										# verify class_labels
										__lowerCamelCase          =      torch.tensor([75, 75, 63, 65, 17, 17]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""class_labels"""]     ,							A_   )   )
										# verify orig_size
										__lowerCamelCase          =      torch.tensor([4_80, 6_40]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""orig_size"""]     ,							A_   )   )
										# verify size
										__lowerCamelCase          =      torch.tensor([8_00, 10_66]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""size"""]     ,							A_   )   )




							@slow
							def   __a   (     self:    Tuple   ):
										# prepare image, target and masks_path
										__lowerCamelCase          =      Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""   )
										with open("""./tests/fixtures/tests_samples/COCO/coco_panoptic_annotations.txt"""     ,							"""r"""   ) as f:
													__lowerCamelCase          =      json.loads(f.read()   )

										__lowerCamelCase          =      {"""file_name""": """000000039769.png""", """image_id""": 3_97_69, """segments_info""": target}

										__lowerCamelCase          =      pathlib.Path("""./tests/fixtures/tests_samples/COCO/coco_panoptic"""   )

										# encode them
										__lowerCamelCase          =      DetaImageProcessor(format="""coco_panoptic"""   )
										__lowerCamelCase          =      image_processing(images=A_     ,							annotations=A_     ,							masks_path=A_     ,							return_tensors="""pt"""   )

										# verify pixel values
										__lowerCamelCase          =      torch.Size([1, 3, 8_00, 10_66]   )
										self.assertEqual(encoding["""pixel_values"""].shape     ,							A_   )

										__lowerCamelCase          =      torch.tensor([0.2_796, 0.3_138, 0.3_481]   )
										self.assertTrue(torch.allclose(encoding["""pixel_values"""][0, 0, 0, :3]     ,							A_     ,							atol=1E-4   )   )

										# verify area
										__lowerCamelCase          =      torch.tensor([147_979.6_875, 165_527.0_469, 484_638.5_938, 11_292.9_375, 5_879.6_562, 7_634.1_147]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""area"""]     ,							A_   )   )
										# verify boxes
										__lowerCamelCase          =      torch.Size([6, 4]   )
										self.assertEqual(encoding["""labels"""][0]["""boxes"""].shape     ,							A_   )
										__lowerCamelCase          =      torch.tensor([0.2_625, 0.5_437, 0.4_688, 0.8_625]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""boxes"""][0]     ,							A_     ,							atol=1E-3   )   )
										# verify image_id
										__lowerCamelCase          =      torch.tensor([3_97_69]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""image_id"""]     ,							A_   )   )
										# verify is_crowd
										__lowerCamelCase          =      torch.tensor([0, 0, 0, 0, 0, 0]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""iscrowd"""]     ,							A_   )   )
										# verify class_labels
										__lowerCamelCase          =      torch.tensor([17, 17, 63, 75, 75, 93]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""class_labels"""]     ,							A_   )   )
										# verify masks
										__lowerCamelCase          =      82_28_73
										self.assertEqual(encoding["""labels"""][0]["""masks"""].sum().item()     ,							A_   )
										# verify orig_size
										__lowerCamelCase          =      torch.tensor([4_80, 6_40]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""orig_size"""]     ,							A_   )   )
										# verify size
										__lowerCamelCase          =      torch.tensor([8_00, 10_66]   )
										self.assertTrue(torch.allclose(encoding["""labels"""][0]["""size"""]     ,							A_   )   )




