code: def test_bbox_clipping(self):
      from sahi.utils.coco import (
          Coco,
          CocoAnnotation,
          CocoCategory,
          CocoImage,
      )
  
      coco = Coco()
      coco.add_category(
          CocoCategory(id=0, name="box", supercategory="box")
      )
      cocoimg = CocoImage(file_name="bboxes.jpg", height=100, width=100)
      cocoimg2 = CocoImage(
          file_name="sample_photo.png", height=1080, width=1920
      )  # negative img
      cocoann = CocoAnnotation(
          bbox=[60, 20, 10, 70],
          category_id=0,
          category_name="box",
          image_id=1,
      )  # bbox totally inside img
      cocoann2 = CocoAnnotation(
          bbox=[120, 110, 60, 30],
          category_id=0,
          category_name="box",
          image_id=1,
      )  # bbox totally outside img
      cocoann3 = CocoAnnotation(
          bbox=[-50, -20, 80, 80],
          category_id=0,
          category_name="box",
          image_id=1,
      )  # x<0   y<0
      cocoann4 = CocoAnnotation(
          bbox=[50, -50, 60, 60],
          category_id=0,
          category_name="box",
          image_id=1,
      )  #  y<0   x+w > imwidth
      cocoann5 = CocoAnnotation(
          bbox=[-50, 50, 70, 70],
          category_id=0,
          category_name="box",
          image_id=1,
      )  #  x<0   y+h > imheight
      cocoann6 = CocoAnnotation(
          bbox=[80, 80, 50, 50],
          category_id=0,
          category_name="box",
          image_id=1,
      )  # x+w > imwidth y+h > imheight
      cocoann7 = CocoAnnotation(
          bbox=[-70, -70, 200, 200],
          category_id=0,
          category_name="box",
          image_id=1,
      )  # bbox totally enclosing img
  
      cocoimg.add_annotation(cocoann)
      cocoimg.add_annotation(cocoann2)
      cocoimg.add_annotation(cocoann3)
      cocoimg.add_annotation(cocoann4)
      cocoimg.add_annotation(cocoann5)
      cocoimg.add_annotation(cocoann6)
      cocoimg.add_annotation(cocoann7)
      coco.add_image(cocoimg)
      coco.add_image(cocoimg2)
  
      coco_with_clipped_bboxes = coco.get_coco_with_clipped_bboxes()
  
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[0].bbox,
          [60, 20, 10, 70],
      )
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[1].bbox,
          [0, 0, 30, 60],
      )
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[2].bbox,
          [50, 0, 50, 10],
      )
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[3].bbox,
          [0, 50, 20, 50],
      )
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[4].bbox,
          [80, 80, 20, 20],
      )
      self.assertEqual(
          coco_with_clipped_bboxes.images[0].annotations[5].bbox,
          [0, 0, 100, 100],
      )
      self.assertIsNotNone(coco_with_clipped_bboxes.images[1])
      self.assertEqual(
          len(coco_with_clipped_bboxes.images[1].annotations), 0
      )
  
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 21 for calling the TestCocoUtils obj's underlying member method code with example usage: obj.test_bbox_clipping() without return types