code: def test_border_polygons(self):
      H, W = 200, 200
      img = np.zeros((H, W, 3))
      img[:, :, 0] = 255.0
      v = Visualizer(img, scale=3)
      mask = np.zeros((H, W))
      mask[:, 100:150] = 1
  
      output = v.draw_binary_mask(mask, color="blue")
      output = output.get_image()[:, :, ::-1]
  
      first_row = {tuple(x.tolist()) for x in output[0]}
      last_row = {tuple(x.tolist()) for x in output[-1]}
      # Check quantization / off-by-1 error:
      # the first and last row must have >=2 colors, because the polygon
      # touches both rows
      self.assertGreaterEqual(len(last_row), 2)
      self.assertGreaterEqual(len(first_row), 2)
      self.assertIn((0, 0, 255), last_row)
      self.assertIn((0, 0, 255), first_row)
  
imports: import numpy
  import os
  import tempfile
  import unittest
  import cv2
  import torch
  from detectron2.data import MetadataCatalog
  from detectron2.structures import BoxMode, Instances, RotatedBoxes
  from detectron2.utils.visualizer import ColorMode, Visualizer
label_desc: Use image node_id 16 for calling the TestVisualizer obj's underlying member method code with example usage: obj.test_border_polygons() without return types