code: def test_get_subsampled_coco(self):
      from sahi.utils.coco import Coco
      from sahi.utils.file import load_json
  
      coco_path = "tests/data/coco_utils/visdrone2019-det-train-first50image.json"
      image_dir = "tests/data/coco_utils/"
      SUBSAMPLE_RATIO = 5
      coco = Coco.from_coco_dict_or_path(coco_path, image_dir=image_dir)
      subsampled_coco = coco.get_subsampled_coco(
          subsample_ratio=SUBSAMPLE_RATIO
      )
      self.assertEqual(
          len(coco.json["images"]),
          50,
      )
      self.assertEqual(
          len(subsampled_coco.json["images"]),
          10,
      )
      self.assertEqual(
          len(coco.images[5].annotations),
          len(subsampled_coco.images[1].annotations),
      )
      self.assertEqual(
          len(coco.images[5].annotations),
          len(subsampled_coco.images[1].annotations),
      )
      self.assertEqual(
          coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          subsampled_coco.image_dir,
          image_dir,
      )
      self.assertEqual(
          subsampled_coco.stats["num_images"],
          len(subsampled_coco.images),
      )
      self.assertEqual(
          subsampled_coco.stats["num_annotations"],
          len(subsampled_coco.json["annotations"]),
      )
  
      vehicle_subsampled_coco = coco.get_subsampled_coco(
          subsample_ratio=SUBSAMPLE_RATIO, category_id=1
      )
      self.assertEqual(
          vehicle_subsampled_coco.stats["num_images_per_category"][
              "vehicle"
          ],
          int(
              coco.stats["num_images_per_category"]["vehicle"]
              / SUBSAMPLE_RATIO
          )
          + 1,
      )
  
      negative_subsampled_coco = coco.get_subsampled_coco(
          subsample_ratio=SUBSAMPLE_RATIO, category_id=-1
      )
      self.assertEqual(
          negative_subsampled_coco.stats["num_images_per_category"][
              "vehicle"
          ],
          coco.stats["num_images_per_category"]["vehicle"],
      )
      self.assertEqual(
          negative_subsampled_coco.stats["num_negative_images"],
          int(coco.stats["num_negative_images"] / SUBSAMPLE_RATIO) + 1,
      )
  
imports: import os
  import shutil
  import unittest
  from sahi.utils.coco import merge, update_categories
  from sahi.utils.file import load_json
label_desc: Use image node_id 16 for calling the TestCocoUtils obj's underlying member method code with example usage: obj.test_get_subsampled_coco() without return types