code: def test_call_segmentation_maps(self):
      # Initialize feature_extractor
      feature_extractor = self.feature_extraction_class(
          **self.feat_extract_dict
      )
      # create random PyTorch tensors
      image_inputs = prepare_image_inputs(
          self.feature_extract_tester,
          equal_resolution=False,
          torchify=True,
      )
      maps = []
      for image in image_inputs:
          self.assertIsInstance(image, torch.Tensor)
          maps.append(torch.zeros(image.shape[-2:]).long())
  
      # Test not batched input
      encoding = feature_extractor(
          image_inputs[0], maps[0], return_tensors="pt"
      )
      self.assertEqual(
          encoding["pixel_values"].shape,
          (
              1,
              self.feature_extract_tester.num_channels,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(
          encoding["labels"].shape,
          (
              1,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(encoding["labels"].dtype, torch.long)
      self.assertTrue(encoding["labels"].min().item() >= 0)
      self.assertTrue(encoding["labels"].max().item() <= 255)
  
      # Test batched
      encoding = feature_extractor(
          image_inputs, maps, return_tensors="pt"
      )
      self.assertEqual(
          encoding["pixel_values"].shape,
          (
              self.feature_extract_tester.batch_size,
              self.feature_extract_tester.num_channels,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(
          encoding["labels"].shape,
          (
              self.feature_extract_tester.batch_size,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(encoding["labels"].dtype, torch.long)
      self.assertTrue(encoding["labels"].min().item() >= 0)
      self.assertTrue(encoding["labels"].max().item() <= 255)
  
      # Test not batched input (PIL images)
      image, segmentation_map = prepare_semantic_single_inputs()
  
      encoding = feature_extractor(
          image, segmentation_map, return_tensors="pt"
      )
      self.assertEqual(
          encoding["pixel_values"].shape,
          (
              1,
              self.feature_extract_tester.num_channels,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(
          encoding["labels"].shape,
          (
              1,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(encoding["labels"].dtype, torch.long)
      self.assertTrue(encoding["labels"].min().item() >= 0)
      self.assertTrue(encoding["labels"].max().item() <= 255)
  
      # Test batched input (PIL images)
      images, segmentation_maps = prepare_semantic_batch_inputs()
  
      encoding = feature_extractor(
          images, segmentation_maps, return_tensors="pt"
      )
      self.assertEqual(
          encoding["pixel_values"].shape,
          (
              2,
              self.feature_extract_tester.num_channels,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(
          encoding["labels"].shape,
          (
              2,
              self.feature_extract_tester.crop_size,
              self.feature_extract_tester.crop_size,
          ),
      )
      self.assertEqual(encoding["labels"].dtype, torch.long)
      self.assertTrue(encoding["labels"].min().item() >= 0)
      self.assertTrue(encoding["labels"].max().item() <= 255)
  
imports: import unittest
  import numpy
  from datasets import load_dataset
  from transformers.testing_utils import require_torch, require_vision
  from transformers.utils import is_torch_available, is_vision_available
  from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs
label_desc: Use image node_id 8 for calling the BeitFeatureExtractionTest obj's underlying member method code with example usage: obj.test_call_segmentation_maps() without return types