code: def test_draw_segmentation_masks_errors(device):
      h, w = 10, 10
  
      masks = torch.randint(
          0, 2, size=(h, w), dtype=torch.bool, device=device
      )
      img = torch.randint(
          0, 256, size=(3, h, w), dtype=torch.uint8, device=device
      )
  
      with pytest.raises(TypeError, match="The image must be a tensor"):
          utils.draw_segmentation_masks(
              image="Not A Tensor Image", masks=masks
          )
      with pytest.raises(ValueError, match="The image dtype must be"):
          img_bad_dtype = torch.randint(
              0, 256, size=(3, h, w), dtype=torch.int64
          )
          utils.draw_segmentation_masks(
              image=img_bad_dtype, masks=masks
          )
      with pytest.raises(
          ValueError, match="Pass individual images, not batches"
      ):
          batch = torch.randint(
              0, 256, size=(10, 3, h, w), dtype=torch.uint8
          )
          utils.draw_segmentation_masks(image=batch, masks=masks)
      with pytest.raises(ValueError, match="Pass an RGB image"):
          one_channel = torch.randint(
              0, 256, size=(1, h, w), dtype=torch.uint8
          )
          utils.draw_segmentation_masks(image=one_channel, masks=masks)
      with pytest.raises(
          ValueError, match="The masks must be of dtype bool"
      ):
          masks_bad_dtype = torch.randint(
              0, 2, size=(h, w), dtype=torch.float
          )
          utils.draw_segmentation_masks(
              image=img, masks=masks_bad_dtype
          )
      with pytest.raises(ValueError, match="masks must be of shape"):
          masks_bad_shape = torch.randint(
              0, 2, size=(3, 2, h, w), dtype=torch.bool
          )
          utils.draw_segmentation_masks(
              image=img, masks=masks_bad_shape
          )
      with pytest.raises(
          ValueError, match="must have the same height and width"
      ):
          masks_bad_shape = torch.randint(
              0, 2, size=(h + 4, w), dtype=torch.bool
          )
          utils.draw_segmentation_masks(
              image=img, masks=masks_bad_shape
          )
      with pytest.raises(
          ValueError,
          match="Number of colors must be equal or larger than the number of objects",
      ):
          utils.draw_segmentation_masks(
              image=img, masks=masks, colors=[]
          )
      with pytest.raises(
          ValueError,
          match="`colors` must be a tuple or a string, or a list thereof",
      ):
          bad_colors = np.array(["red", "blue"])  # should be a list
          utils.draw_segmentation_masks(
              image=img, masks=masks, colors=bad_colors
          )
      with pytest.raises(
          ValueError,
          match="If passed as tuple, colors should be an RGB triplet",
      ):
          bad_colors = ("red", "blue")  # should be a list
          utils.draw_segmentation_masks(
              image=img, masks=masks, colors=bad_colors
          )
  
imports: import os
  import re
  import sys
  import tempfile
  from io import BytesIO
  import numpy
  import pytest
  import torch
  import torchvision.transforms.functional
  import torchvision.utils
  from common_utils import assert_equal, cpu_and_cuda
  from PIL import __version__, Image, ImageColor
  from torchvision.transforms.v2.functional import to_dtype
label_desc: Use image node_id 16 for calling a global function with example usage: test_draw_segmentation_masks_errors(device) without return types