code: def test_slice_coco(self):
      import shutil
  
      coco_annotation_file_path = (
          "tests/data/coco_utils/terrain1_coco.json"
      )
      image_dir = "tests/data/coco_utils/"
      output_coco_annotation_file_name = "test_out"
      output_dir = "tests/data/coco_utils/test_out/"
      ignore_negative_samples = True
      coco_dict, _ = slice_coco(
          coco_annotation_file_path=coco_annotation_file_path,
          image_dir=image_dir,
          output_coco_annotation_file_name=output_coco_annotation_file_name,
          output_dir=output_dir,
          ignore_negative_samples=ignore_negative_samples,
          slice_height=512,
          slice_width=512,
          overlap_height_ratio=0.1,
          overlap_width_ratio=0.4,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(coco_dict["images"]), 5)
      self.assertEqual(coco_dict["images"][1]["height"], 512)
      self.assertEqual(coco_dict["images"][1]["width"], 512)
      self.assertEqual(len(coco_dict["annotations"]), 14)
      self.assertEqual(coco_dict["annotations"][2]["id"], 3)
      self.assertEqual(coco_dict["annotations"][2]["image_id"], 2)
      self.assertEqual(coco_dict["annotations"][2]["category_id"], 1)
      self.assertEqual(coco_dict["annotations"][2]["area"], 12483)
      self.assertEqual(
          coco_dict["annotations"][2]["bbox"],
          [340, 204, 73, 171],
      )
  
      shutil.rmtree(output_dir, ignore_errors=True)
  
      coco_annotation_file_path = (
          "tests/data/coco_utils/terrain1_coco.json"
      )
      image_dir = "tests/data/coco_utils/"
      output_coco_annotation_file_name = "test_out"
      output_dir = "tests/data/coco_utils/test_out/"
      ignore_negative_samples = False
      coco_dict, _ = slice_coco(
          coco_annotation_file_path=coco_annotation_file_path,
          image_dir=image_dir,
          output_coco_annotation_file_name=output_coco_annotation_file_name,
          output_dir=output_dir,
          ignore_negative_samples=ignore_negative_samples,
          slice_height=512,
          slice_width=512,
          overlap_height_ratio=0.1,
          overlap_width_ratio=0.4,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(coco_dict["images"]), 18)
      self.assertEqual(coco_dict["images"][1]["height"], 512)
      self.assertEqual(coco_dict["images"][1]["width"], 512)
      self.assertEqual(len(coco_dict["annotations"]), 14)
      self.assertEqual(coco_dict["annotations"][2]["id"], 3)
      self.assertEqual(coco_dict["annotations"][2]["image_id"], 14)
      self.assertEqual(coco_dict["annotations"][2]["category_id"], 1)
      self.assertEqual(coco_dict["annotations"][2]["area"], 12483)
      self.assertEqual(
          coco_dict["annotations"][2]["bbox"],
          [340, 204, 73, 171],
      )
  
      shutil.rmtree(output_dir, ignore_errors=True)
  
file_path: sahi/tests/test_slicing.py
imports: import unittest
  import numpy
  from PIL import Image
  from sahi.slicing import shift_bboxes, shift_masks, slice_coco, slice_image
  from sahi.utils.coco import Coco
  from sahi.utils.cv import read_image
label_desc: Use image node_id 2 for calling the TestSlicing obj's underlying member method code with example usage: obj.test_slice_coco() without return types