code: def test_boxes_to_mask(self, device, dtype):
      t_box1 = torch.tensor(
          [[[1.0, 1.0], [3.0, 1.0], [3.0, 2.0], [1.0, 2.0]]],
          device=device,
          dtype=dtype,
      )  # (1, 4, 2)
      t_box2 = torch.tensor(
          [[[2.0, 2.0], [4.0, 2.0], [4.0, 5.0], [2.0, 4.0]]],
          device=device,
          dtype=dtype,
      )  # (1, 4, 2)
      box1, box2 = Boxes(t_box1), Boxes(t_box2)
      two_boxes = Boxes(torch.cat([t_box1, t_box2]))  # (2, 4, 2)
      batched_boxes = Boxes(
          torch.stack([t_box1, t_box2])
      )  # (2, 1, 4, 2)
  
      height, width = 7, 5
  
      expected_mask1 = torch.tensor(
          [
              [
                  [0, 0, 0, 0, 0],
                  [0, 1, 1, 1, 0],
                  [0, 1, 1, 1, 0],
                  [0, 0, 0, 0, 0],
                  [0, 0, 0, 0, 0],
                  [0, 0, 0, 0, 0],
                  [0, 0, 0, 0, 0],
              ]
          ],
          device=device,
          dtype=dtype,
      )
  
      expected_mask2 = torch.tensor(
          [
              [
                  [0, 0, 0, 0, 0],
                  [0, 0, 0, 0, 0],
                  [0, 0, 1, 1, 1],
                  [0, 0, 1, 1, 1],
                  [0, 0, 1, 1, 1],
                  [0, 0, 1, 1, 1],
                  [0, 0, 0, 0, 0],
              ]
          ],
          device=device,
          dtype=dtype,
      )
      expected_two_masks = torch.cat([expected_mask1, expected_mask2])
      expected_batched_masks = torch.stack(
          [expected_mask1, expected_mask2]
      )
  
      mask1 = box1.to_mask(height, width)
      mask2 = box2.to_mask(height, width)
      two_masks = two_boxes.to_mask(height, width)
      batched_masks = batched_boxes.to_mask(height, width)
  
      assert mask1.shape == expected_mask1.shape
      assert_close(mask1, expected_mask1)
  
      assert mask2.shape == expected_mask2.shape
      assert_close(mask2, expected_mask2)
  
      assert two_masks.shape == expected_two_masks.shape
      assert_close(two_masks, expected_two_masks)
  
      assert batched_masks.shape == expected_batched_masks.shape
      assert_close(batched_masks, expected_batched_masks)
  
imports: from functools import partial
  import pytest
  import torch
  from kornia.geometry.boxes import Boxes, Boxes3D
  from kornia.testing import assert_close, gradcheck, tensor_to_gradcheck_var
label_desc: Use image node_id 8 for calling the TestBoxes2D obj's underlying member method code with example usage: obj.test_boxes_to_mask(device, dtype) without return types