code: def test_call_pytorch_with_coco_detection_annotations(self):
      # prepare image and target
      image = Image.open(
          "./tests/fixtures/tests_samples/COCO/000000039769.png"
      )
      with open(
          "./tests/fixtures/tests_samples/COCO/coco_annotations.txt",
          "r",
      ) as f:
          target = json.loads(f.read())
  
      target = {"image_id": 39769, "annotations": target}
  
      # encode them
      feature_extractor = YolosFeatureExtractor.from_pretrained(
          "hustvl/yolos-small"
      )
      encoding = feature_extractor(
          images=image, annotations=target, return_tensors="pt"
      )
  
      # verify pixel values
      expected_shape = torch.Size([1, 3, 800, 1066])
      self.assertEqual(encoding["pixel_values"].shape, expected_shape)
  
      expected_slice = torch.tensor([0.2796, 0.3138, 0.3481])
      self.assertTrue(
          torch.allclose(
              encoding["pixel_values"][0, 0, 0, :3],
              expected_slice,
              atol=1e-4,
          )
      )
  
      # verify area
      expected_area = torch.tensor(
          [
              5887.9600,
              11250.2061,
              489353.8438,
              837122.7500,
              147967.5156,
              165732.3438,
          ]
      )
      self.assertTrue(
          torch.allclose(encoding["labels"][0]["area"], expected_area)
      )
      # verify boxes
      expected_boxes_shape = torch.Size([6, 4])
      self.assertEqual(
          encoding["labels"][0]["boxes"].shape, expected_boxes_shape
      )
      expected_boxes_slice = torch.tensor(
          [0.5503, 0.2765, 0.0604, 0.2215]
      )
      self.assertTrue(
          torch.allclose(
              encoding["labels"][0]["boxes"][0],
              expected_boxes_slice,
              atol=1e-3,
          )
      )
      # verify image_id
      expected_image_id = torch.tensor([39769])
      self.assertTrue(
          torch.allclose(
              encoding["labels"][0]["image_id"], expected_image_id
          )
      )
      # verify is_crowd
      expected_is_crowd = torch.tensor([0, 0, 0, 0, 0, 0])
      self.assertTrue(
          torch.allclose(
              encoding["labels"][0]["iscrowd"], expected_is_crowd
          )
      )
      # verify class_labels
      expected_class_labels = torch.tensor([75, 75, 63, 65, 17, 17])
      self.assertTrue(
          torch.allclose(
              encoding["labels"][0]["class_labels"],
              expected_class_labels,
          )
      )
      # verify orig_size
      expected_orig_size = torch.tensor([480, 640])
      self.assertTrue(
          torch.allclose(
              encoding["labels"][0]["orig_size"], expected_orig_size
          )
      )
      # verify size
      expected_size = torch.tensor([800, 1066])
      self.assertTrue(
          torch.allclose(encoding["labels"][0]["size"], expected_size)
      )
  
imports: import json
  import pathlib
  import unittest
  import numpy
  from transformers.testing_utils import require_torch, require_vision, slow
  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 9 for calling the YolosFeatureExtractionTest obj's underlying member method code with example usage: obj.test_call_pytorch_with_coco_detection_annotations() without return types