

import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import MaskFormerForInstanceSegmentation, MaskFormerModel

     if is_vision_available():
          from transformers import MaskFormerImageProcessor

if is_vision_available():
     from PIL import Image


class 		_A       :





      def __init__(  self    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__=2    ,						SCREAMING_SNAKE_CASE__=True    ,						SCREAMING_SNAKE_CASE__=False    ,						SCREAMING_SNAKE_CASE__=10    ,						SCREAMING_SNAKE_CASE__=3    ,						SCREAMING_SNAKE_CASE__=32 * 4    ,						SCREAMING_SNAKE_CASE__=32 * 6    ,						SCREAMING_SNAKE_CASE__=4    ,						SCREAMING_SNAKE_CASE__=32    ,						)   ->					int:
         lowerCamelCase__						=			parent
         lowerCamelCase__						=			batch_size
         lowerCamelCase__						=			is_training
         lowerCamelCase__						=			use_auxiliary_loss
         lowerCamelCase__						=			num_queries
         lowerCamelCase__						=			num_channels
         lowerCamelCase__						=			min_size
         lowerCamelCase__						=			max_size
         lowerCamelCase__						=			num_labels
         lowerCamelCase__						=			mask_feature_size





      def 					_lowerCamelCase  (  self		)   ->					List[Any]:
         lowerCamelCase__						=			floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]		).to(
             SCREAMING_SNAKE_CASE__		)

         lowerCamelCase__						=			torch.ones([self.batch_size, self.min_size, self.max_size]    ,						device=SCREAMING_SNAKE_CASE__		)

         lowerCamelCase__						=			(
             torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]    ,						device=SCREAMING_SNAKE_CASE__		) > 0.5
         ).float()
         lowerCamelCase__						=			(torch.rand((self.batch_size, self.num_labels)    ,						device=SCREAMING_SNAKE_CASE__		) > 0.5).long()

         lowerCamelCase__						=			self.get_config()
         return config, pixel_values, pixel_mask, mask_labels, class_labels





      def 					_lowerCamelCase  (  self		)   ->					Optional[int]:
         return MaskFormerConfig.from_backbone_and_decoder_configs(
             backbone_config=SwinConfig(
                 depths=[1, 1, 1, 1]    ,						)    ,						decoder_config=DetrConfig(
                 decoder_ffn_dim=128    ,						num_queries=self.num_queries    ,						decoder_attention_heads=2    ,						d_model=self.mask_feature_size    ,						)    ,						mask_feature_size=self.mask_feature_size    ,						fpn_feature_size=self.mask_feature_size    ,						num_channels=self.num_channels    ,						num_labels=self.num_labels    ,						)





      def 					_lowerCamelCase  (  self		)   ->					int:
         lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__						=			self.prepare_config_and_inputs()
         lowerCamelCase__						=			{"pixel_values": pixel_values, "pixel_mask": pixel_mask}
         return config, inputs_dict





      def 					_lowerCamelCase  (  self    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__		)   ->					Optional[Any]:
         lowerCamelCase__						=			output.encoder_hidden_states
         lowerCamelCase__						=			output.pixel_decoder_hidden_states
         lowerCamelCase__						=			output.transformer_decoder_hidden_states

         self.parent.assertTrue(len(SCREAMING_SNAKE_CASE__		)    ,						len(config.backbone_config.depths		)		)
         self.parent.assertTrue(len(SCREAMING_SNAKE_CASE__		)    ,						len(config.backbone_config.depths		)		)
         self.parent.assertTrue(len(SCREAMING_SNAKE_CASE__		)    ,						config.decoder_config.decoder_layers		)





      def 					_lowerCamelCase  (  self    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__=False		)   ->					Optional[int]:
         with torch.no_grad():
            lowerCamelCase__						=			MaskFormerModel(config=SCREAMING_SNAKE_CASE__		)
            model.to(SCREAMING_SNAKE_CASE__		)
            model.eval()

            lowerCamelCase__						=			model(pixel_values=SCREAMING_SNAKE_CASE__    ,						pixel_mask=SCREAMING_SNAKE_CASE__		)
            lowerCamelCase__						=			model(SCREAMING_SNAKE_CASE__    ,						output_hidden_states=SCREAMING_SNAKE_CASE__		)
         # the correct shape of output.transformer_decoder_hidden_states ensure the correcteness of the
         # encoder and pixel decoder
         self.parent.assertEqual(
             output.transformer_decoder_last_hidden_state.shape    ,						(self.batch_size, self.num_queries, self.mask_feature_size)    ,						)
         # let's ensure the other two hidden state exists
         self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None		)
         self.parent.assertTrue(output.encoder_last_hidden_state is not None		)

         if output_hidden_states:
            self.check_output_hidden_state(SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__		)   ->					Union[str, Any]:
         lowerCamelCase__						=			MaskFormerForInstanceSegmentation(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()

         def comm_check_on_output(SCREAMING_SNAKE_CASE__		):
            # let's still check that all the required stuff is there
            self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None		)
            self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None		)
            self.parent.assertTrue(result.encoder_last_hidden_state is not None		)
            # okay, now we need to check the logits shape
            # due to the encoder compression, masks have a //4 spatial size
            self.parent.assertEqual(
                result.masks_queries_logits.shape    ,						(self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)    ,						)
            # + 1 for null class
            self.parent.assertEqual(
                result.class_queries_logits.shape    ,						(self.batch_size, self.num_queries, self.num_labels + 1)		)

         with torch.no_grad():
            lowerCamelCase__						=			model(pixel_values=SCREAMING_SNAKE_CASE__    ,						pixel_mask=SCREAMING_SNAKE_CASE__		)
            lowerCamelCase__						=			model(SCREAMING_SNAKE_CASE__		)

            comm_check_on_output(SCREAMING_SNAKE_CASE__		)

            lowerCamelCase__						=			model(
                pixel_values=SCREAMING_SNAKE_CASE__    ,						pixel_mask=SCREAMING_SNAKE_CASE__    ,						mask_labels=SCREAMING_SNAKE_CASE__    ,						class_labels=SCREAMING_SNAKE_CASE__		)

         comm_check_on_output(SCREAMING_SNAKE_CASE__		)

         self.parent.assertTrue(result.loss is not None		)
         self.parent.assertEqual(result.loss.shape    ,						torch.Size([1]		)		)






@require_torch
class 		_A       (			__a				,       __a				,       unittest.TestCase					):
      __a								=	(MaskFormerModel, MaskFormerForInstanceSegmentation) if is_torch_available() else ()
      __a								=	(
          {'feature-extraction': MaskFormerModel, 'image-segmentation': MaskFormerForInstanceSegmentation}
          if is_torch_available()
          else {}
      )

      __a								=	False
      __a								=	False
      __a								=	False
      __a								=	False





      def 					_lowerCamelCase  (  self		)   ->					Dict:
         lowerCamelCase__						=			MaskFormerModelTester(self		)
         lowerCamelCase__						=			ConfigTester(self    ,						config_class=SCREAMING_SNAKE_CASE__    ,						has_text_modality=SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self		)   ->					List[str]:
         self.config_tester.run_common_tests()





      def 					_lowerCamelCase  (  self		)   ->					Optional[int]:
         lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs_for_common()
         self.model_tester.create_and_check_maskformer_model(SCREAMING_SNAKE_CASE__    ,						**SCREAMING_SNAKE_CASE__    ,						output_hidden_states=SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self		)   ->					Tuple:
         lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_maskformer_instance_segmentation_head_model(*SCREAMING_SNAKE_CASE__		)





      @unittest.skip(reason="MaskFormer does not use inputs_embeds"		)
      def 					_lowerCamelCase  (  self		)   ->					Dict:
         pass





      @unittest.skip(reason="MaskFormer does not have a get_input_embeddings method"		)
      def 					_lowerCamelCase  (  self		)   ->					Optional[int]:
         pass





      @unittest.skip(reason="MaskFormer is not a generative model"		)
      def 					_lowerCamelCase  (  self		)   ->					Union[str, Any]:
         pass





      @unittest.skip(reason="MaskFormer does not use token embeddings"		)
      def 					_lowerCamelCase  (  self		)   ->					Union[str, Any]:
         pass





      @require_torch_multi_gpu
      @unittest.skip(
          reason="MaskFormer has some layers using `add_module` which doesn't work well with `nn.DataParallel`"		)
      def 					_lowerCamelCase  (  self		)   ->					Tuple:
         pass





      @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."		)
      def 					_lowerCamelCase  (  self		)   ->					str:
         pass





      def 					_lowerCamelCase  (  self		)   ->					List[str]:
         lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs_for_common()

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

            lowerCamelCase__						=			["pixel_values"]
            self.assertListEqual(arg_names[:1]    ,						SCREAMING_SNAKE_CASE__		)





      @slow
      def 					_lowerCamelCase  (  self		)   ->					Union[str, Any]:
         for model_name in ["facebook/maskformer-swin-small-coco"]:
            lowerCamelCase__						=			MaskFormerModel.from_pretrained(SCREAMING_SNAKE_CASE__		)
            self.assertIsNotNone(SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self		)   ->					List[str]:
         lowerCamelCase__						=			(self.model_tester.min_size,) * 2
         lowerCamelCase__						=			{
             "pixel_values": torch.randn((2, 3, *size)    ,						device=SCREAMING_SNAKE_CASE__		),
             "mask_labels": torch.randn((2, 10, *size)    ,						device=SCREAMING_SNAKE_CASE__		),
             "class_labels": torch.zeros(2    ,						10    ,						device=SCREAMING_SNAKE_CASE__		).long(),
         }

         lowerCamelCase__						=			MaskFormerForInstanceSegmentation(MaskFormerConfig()		).to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__		)
         self.assertTrue(outputs.loss is not None		)





      def 					_lowerCamelCase  (  self		)   ->					List[str]:
         lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs_for_common()
         self.model_tester.create_and_check_maskformer_model(SCREAMING_SNAKE_CASE__    ,						**SCREAMING_SNAKE_CASE__    ,						output_hidden_states=SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self		)   ->					int:
         lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
            lowerCamelCase__						=			model_class(SCREAMING_SNAKE_CASE__		).to(SCREAMING_SNAKE_CASE__		)
            lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__    ,						output_attentions=SCREAMING_SNAKE_CASE__		)
            self.assertTrue(outputs.attentions is not None		)





      def 					_lowerCamelCase  (  self		)   ->					Dict:
         if not self.model_tester.is_training:
            return
         # only MaskFormerForInstanceSegmentation has the loss
         lowerCamelCase__						=			self.all_model_classes[1]
         lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs()

         lowerCamelCase__						=			model_class(SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.train()

         lowerCamelCase__						=			model(SCREAMING_SNAKE_CASE__    ,						mask_labels=SCREAMING_SNAKE_CASE__    ,						class_labels=SCREAMING_SNAKE_CASE__		).loss
         loss.backward()





      def 					_lowerCamelCase  (  self		)   ->					Optional[Any]:
         # only MaskFormerForInstanceSegmentation has the loss
         lowerCamelCase__						=			self.all_model_classes[1]
         lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__					,       lowerCamelCase__						=			self.model_tester.prepare_config_and_inputs()
         lowerCamelCase__						=			True
         lowerCamelCase__						=			True

         lowerCamelCase__						=			model_class(SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.train()

         lowerCamelCase__						=			model(SCREAMING_SNAKE_CASE__    ,						mask_labels=SCREAMING_SNAKE_CASE__    ,						class_labels=SCREAMING_SNAKE_CASE__		)

         lowerCamelCase__						=			outputs.encoder_hidden_states[0]
         encoder_hidden_states.retain_grad()

         lowerCamelCase__						=			outputs.pixel_decoder_hidden_states[0]
         pixel_decoder_hidden_states.retain_grad()
         # we requires_grad=True in inputs_embeds (line 2152), the original implementation don't
         lowerCamelCase__						=			outputs.transformer_decoder_hidden_states[0]
         transformer_decoder_hidden_states.retain_grad()

         lowerCamelCase__						=			outputs.attentions[0]
         attentions.retain_grad()

         outputs.loss.backward(retain_graph=SCREAMING_SNAKE_CASE__		)

         self.assertIsNotNone(encoder_hidden_states.grad		)
         self.assertIsNotNone(pixel_decoder_hidden_states.grad		)
         self.assertIsNotNone(transformer_decoder_hidden_states.grad		)
         self.assertIsNotNone(attentions.grad		)






SCREAMING_SNAKE_CASE_     :			Any	  =			1e-4



def 	UpperCAmelCase__   (				)      ->      Dict:




   """simple docstring"""
   lowerCamelCase__						=			Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"   )
   return image


@require_vision
@slow
class 		_A       (			unittest.TestCase					):





      @cached_property
      def 					_lowerCamelCase  (  self		)   ->					Optional[int]:
         return (
             MaskFormerImageProcessor.from_pretrained("facebook/maskformer-swin-small-coco"		)
             if is_vision_available()
             else None
         )





      def 					_lowerCamelCase  (  self		)   ->					str:
         lowerCamelCase__						=			MaskFormerModel.from_pretrained("facebook/maskformer-swin-small-coco"		).to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			self.default_image_processor
         lowerCamelCase__						=			prepare_img()
         lowerCamelCase__						=			image_processor(SCREAMING_SNAKE_CASE__    ,						return_tensors="pt"		).to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			inputs["pixel_values"].shape
         # check size is divisible by 32
         self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
         # check size
         self.assertEqual(SCREAMING_SNAKE_CASE__    ,						(1, 3, 800, 1088)		)

         with torch.no_grad():
            lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__		)

         lowerCamelCase__						=			torch.tensor(
             [[-0.04_82, 0.92_28, 0.49_51], [-0.25_47, 0.80_17, 0.85_27], [-0.00_69, 0.33_85, -0.00_89]]		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(
             torch.allclose(
                 outputs.encoder_last_hidden_state[0, 0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)

         lowerCamelCase__						=			torch.tensor(
             [[-0.84_22, -0.84_34, -0.97_18], [-1.01_44, -0.55_65, -0.41_95], [-1.00_38, -0.44_84, -0.19_61]]		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(
             torch.allclose(
                 outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)

         lowerCamelCase__						=			torch.tensor(
             [[0.28_52, -0.01_59, 0.97_35], [0.62_54, 0.18_58, 0.85_29], [-0.06_80, -0.41_16, 1.84_13]]		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(
             torch.allclose(
                 outputs.transformer_decoder_last_hidden_state[0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)





      def 					_lowerCamelCase  (  self		)   ->					Optional[Any]:
         lowerCamelCase__						=			(
             MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"		)
             .to(SCREAMING_SNAKE_CASE__		)
             .eval()
         )
         lowerCamelCase__						=			self.default_image_processor
         lowerCamelCase__						=			prepare_img()
         lowerCamelCase__						=			image_processor(SCREAMING_SNAKE_CASE__    ,						return_tensors="pt"		).to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			inputs["pixel_values"].shape
         # check size is divisible by 32
         self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
         # check size
         self.assertEqual(SCREAMING_SNAKE_CASE__    ,						(1, 3, 800, 1088)		)

         with torch.no_grad():
            lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__		)
         # masks_queries_logits
         lowerCamelCase__						=			outputs.masks_queries_logits
         self.assertEqual(
             masks_queries_logits.shape    ,						(1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)    ,						)
         lowerCamelCase__						=			[
             [-1.3_73_71_24, -1.7_72_49_37, -1.9_36_42_33],
             [-1.5_97_72_81, -1.9_86_79_39, -2.1_52_36_95],
             [-1.5_79_53_98, -1.9_26_98_32, -2.09_39_42],
         ]
         lowerCamelCase__						=			torch.tensor(SCREAMING_SNAKE_CASE__		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)
         # class_queries_logits
         lowerCamelCase__						=			outputs.class_queries_logits
         self.assertEqual(
             class_queries_logits.shape    ,						(1, model.config.decoder_config.num_queries, model.config.num_labels + 1)		)
         lowerCamelCase__						=			torch.tensor(
             [
                 [1.6512e00, -5.2572e00, -3.3519e00],
                 [3.6169e-02, -5.9025e00, -2.9313e00],
                 [1.0766e-04, -7.7630e00, -5.1263e00],
             ]		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)





      def 					_lowerCamelCase  (  self		)   ->					str:
         lowerCamelCase__						=			(
             MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-resnet101-coco-stuff"		)
             .to(SCREAMING_SNAKE_CASE__		)
             .eval()
         )
         lowerCamelCase__						=			self.default_image_processor
         lowerCamelCase__						=			prepare_img()
         lowerCamelCase__						=			image_processor(SCREAMING_SNAKE_CASE__    ,						return_tensors="pt"		).to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			inputs["pixel_values"].shape
         # check size is divisible by 32
         self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
         # check size
         self.assertEqual(SCREAMING_SNAKE_CASE__    ,						(1, 3, 800, 1088)		)

         with torch.no_grad():
            lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__		)
         # masks_queries_logits
         lowerCamelCase__						=			outputs.masks_queries_logits
         self.assertEqual(
             masks_queries_logits.shape    ,						(1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)    ,						)
         lowerCamelCase__						=			[[-0.90_46, -2.63_66, -4.60_62], [-3.41_79, -5.78_90, -8.80_57], [-4.91_79, -7.65_60, -10.77_11]]
         lowerCamelCase__						=			torch.tensor(SCREAMING_SNAKE_CASE__		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)
         # class_queries_logits
         lowerCamelCase__						=			outputs.class_queries_logits
         self.assertEqual(
             class_queries_logits.shape    ,						(1, model.config.decoder_config.num_queries, model.config.num_labels + 1)		)
         lowerCamelCase__						=			torch.tensor(
             [[4.71_88, -3.25_85, -2.88_57], [6.68_71, -2.91_81, -1.24_87], [7.24_49, -2.27_64, -2.18_74]]		).to(SCREAMING_SNAKE_CASE__		)
         self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]    ,						SCREAMING_SNAKE_CASE__    ,						atol=SCREAMING_SNAKE_CASE__		)		)





      def 					_lowerCamelCase  (  self		)   ->					Optional[int]:
         lowerCamelCase__						=			(
             MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"		)
             .to(SCREAMING_SNAKE_CASE__		)
             .eval()
         )
         lowerCamelCase__						=			self.default_image_processor

         lowerCamelCase__						=			image_processor(
             [np.zeros((3, 800, 1333)		), np.zeros((3, 800, 1333)		)]    ,						segmentation_maps=[np.zeros((384, 384)		).astype(np.floataa		), np.zeros((384, 384)		).astype(np.floataa		)]    ,						return_tensors="pt"    ,						)

         lowerCamelCase__						=			inputs["pixel_values"].to(SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			[el.to(SCREAMING_SNAKE_CASE__		) for el in inputs["mask_labels"]]
         lowerCamelCase__						=			[el.to(SCREAMING_SNAKE_CASE__		) for el in inputs["class_labels"]]

         with torch.no_grad():
            lowerCamelCase__						=			model(**SCREAMING_SNAKE_CASE__		)

         self.assertTrue(outputs.loss is not None		)







"""simple docstring"""




# Algorithm for the pigeonhole sorting





def 	UpperCAmelCase__   (				A__   )      ->      Dict:




   """simple docstring"""
   lowerCamelCase__						=			min(A__   )  # min() finds the minimum value
   lowerCamelCase__						=			max(A__   )  # max() finds the maximum value

   lowerCamelCase__						=			max_val - min_val + 1  # size is difference of max and min values plus one

   # list of pigeonholes of size equal to the variable size
   lowerCamelCase__						=			[0] * size

   # Populate the pigeonholes.
   for x in a:
      assert isinstance(A__	,    A__   ), "integers only please"
      holes[x - min_val] += 1

   # Putting the elements back into the array in an order.
   lowerCamelCase__						=			0
   for count in range(A__   ):
      while holes[count] > 0:
         holes[count] -= 1
         lowerCamelCase__						=			count + min_val
         i += 1



def 	UpperCAmelCase__   (				)      ->      Optional[int]:




   """simple docstring"""
   lowerCamelCase__						=			[8, 3, 2, 7, 4, 6, 8]
   pigeonhole_sort(A__   )
   print("Sorted order is:"	,    " ".join(A__   )   )


if __name__ == "__main__":
     main()




