code: def test_from_instance_masks(self):
      bitmap_masks = BitmapMasks.random()
      boxes = HorizontalBoxes.from_instance_masks(bitmap_masks)
      self.assertIsInstance(boxes, HorizontalBoxes)
      self.assertEqual(len(boxes), len(bitmap_masks))
      polygon_masks = PolygonMasks.random()
      boxes = HorizontalBoxes.from_instance_masks(polygon_masks)
      self.assertIsInstance(boxes, HorizontalBoxes)
      self.assertEqual(len(boxes), len(bitmap_masks))
      # zero length masks
      bitmap_masks = BitmapMasks.random(num_masks=0)
      boxes = HorizontalBoxes.from_instance_masks(bitmap_masks)
      self.assertIsInstance(boxes, HorizontalBoxes)
      self.assertEqual(len(boxes), 0)
      polygon_masks = PolygonMasks.random(num_masks=0)
      boxes = HorizontalBoxes.from_instance_masks(polygon_masks)
      self.assertIsInstance(boxes, HorizontalBoxes)
      self.assertEqual(len(boxes), 0)
  
imports: import random
  from math import sqrt
  from unittest import TestCase
  import cv2
  import numpy
  import torch
  from mmengine.testing import assert_allclose
  from mmdet.structures.bbox import HorizontalBoxes
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
label_desc: Use image node_id 13 for calling the TestHorizontalBoxes obj's underlying member method code with example usage: obj.test_from_instance_masks() without return types