code: def test_integration_torch_image_segmentation(self):
      model_id = "facebook/detr-resnet-50-panoptic"
      image_segmenter = pipeline(
          "image-segmentation",
          model=model_id,
          threshold=0.0,
          overlap_mask_area_threshold=0.0,
      )
  
      outputs = image_segmenter(
          "http://images.cocodataset.org/val2017/000000039769.jpg",
      )
  
      # Shortening by hashing
      for o in outputs:
          o["mask"] = mask_to_test_readable(o["mask"])
  
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              {
                  "score": 0.9094,
                  "label": "blanket",
                  "mask": {
                      "hash": "dcff19a97a",
                      "shape": (480, 640),
                      "white_pixels": 16617,
                  },
              },
              {
                  "score": 0.9941,
                  "label": "cat",
                  "mask": {
                      "hash": "9c0af87bd0",
                      "shape": (480, 640),
                      "white_pixels": 59185,
                  },
              },
              {
                  "score": 0.9987,
                  "label": "remote",
                  "mask": {
                      "hash": "c7870600d6",
                      "shape": (480, 640),
                      "white_pixels": 4182,
                  },
              },
              {
                  "score": 0.9995,
                  "label": "remote",
                  "mask": {
                      "hash": "ef899a25fd",
                      "shape": (480, 640),
                      "white_pixels": 2275,
                  },
              },
              {
                  "score": 0.9722,
                  "label": "couch",
                  "mask": {
                      "hash": "37b8446ac5",
                      "shape": (480, 640),
                      "white_pixels": 172380,
                  },
              },
              {
                  "score": 0.9994,
                  "label": "cat",
                  "mask": {
                      "hash": "6a09d3655e",
                      "shape": (480, 640),
                      "white_pixels": 52561,
                  },
              },
          ],
      )
  
      outputs = image_segmenter(
          [
              "http://images.cocodataset.org/val2017/000000039769.jpg",
              "http://images.cocodataset.org/val2017/000000039769.jpg",
          ],
      )
  
      # Shortening by hashing
      for output in outputs:
          for o in output:
              o["mask"] = mask_to_test_readable(o["mask"])
  
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              [
                  {
                      "score": 0.9094,
                      "label": "blanket",
                      "mask": {
                          "hash": "dcff19a97a",
                          "shape": (480, 640),
                          "white_pixels": 16617,
                      },
                  },
                  {
                      "score": 0.9941,
                      "label": "cat",
                      "mask": {
                          "hash": "9c0af87bd0",
                          "shape": (480, 640),
                          "white_pixels": 59185,
                      },
                  },
                  {
                      "score": 0.9987,
                      "label": "remote",
                      "mask": {
                          "hash": "c7870600d6",
                          "shape": (480, 640),
                          "white_pixels": 4182,
                      },
                  },
                  {
                      "score": 0.9995,
                      "label": "remote",
                      "mask": {
                          "hash": "ef899a25fd",
                          "shape": (480, 640),
                          "white_pixels": 2275,
                      },
                  },
                  {
                      "score": 0.9722,
                      "label": "couch",
                      "mask": {
                          "hash": "37b8446ac5",
                          "shape": (480, 640),
                          "white_pixels": 172380,
                      },
                  },
                  {
                      "score": 0.9994,
                      "label": "cat",
                      "mask": {
                          "hash": "6a09d3655e",
                          "shape": (480, 640),
                          "white_pixels": 52561,
                      },
                  },
              ],
              [
                  {
                      "score": 0.9094,
                      "label": "blanket",
                      "mask": {
                          "hash": "dcff19a97a",
                          "shape": (480, 640),
                          "white_pixels": 16617,
                      },
                  },
                  {
                      "score": 0.9941,
                      "label": "cat",
                      "mask": {
                          "hash": "9c0af87bd0",
                          "shape": (480, 640),
                          "white_pixels": 59185,
                      },
                  },
                  {
                      "score": 0.9987,
                      "label": "remote",
                      "mask": {
                          "hash": "c7870600d6",
                          "shape": (480, 640),
                          "white_pixels": 4182,
                      },
                  },
                  {
                      "score": 0.9995,
                      "label": "remote",
                      "mask": {
                          "hash": "ef899a25fd",
                          "shape": (480, 640),
                          "white_pixels": 2275,
                      },
                  },
                  {
                      "score": 0.9722,
                      "label": "couch",
                      "mask": {
                          "hash": "37b8446ac5",
                          "shape": (480, 640),
                          "white_pixels": 172380,
                      },
                  },
                  {
                      "score": 0.9994,
                      "label": "cat",
                      "mask": {
                          "hash": "6a09d3655e",
                          "shape": (480, 640),
                          "white_pixels": 52561,
                      },
                  },
              ],
          ],
      )
  
imports: import tempfile
  import unittest
  from typing import Dict
  import datasets
  import numpy
  import requests
  from datasets import load_dataset
  from huggingface_hub.utils import insecure_hashlib
  from transformers import MODEL_FOR_IMAGE_SEGMENTATION_MAPPING, MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING, MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING, AutoImageProcessor, AutoModelForImageSegmentation, AutoModelForInstanceSegmentation, DetrForSegmentation, ImageSegmentationPipeline, MaskFormerForInstanceSegmentation, is_vision_available, pipeline
  from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_timm, require_torch, require_vision, slow
  from .test_pipelines_common import ANY
label_desc: Use image node_id 7 for calling the ImageSegmentationPipelineTests obj's underlying member method code with example usage: obj.test_integration_torch_image_segmentation() without return types