class_docstr: 2D boxes containing N or BxN boxes.
  
  Args:
      boxes: 2D boxes, shape of :math:`(N, 4, 2)`, :math:`(B, N, 4, 2)` or a list of :math:`(N, 4, 2)`.
          See below for more details.
      raise_if_not_floating_point: flag to control floating point casting behaviour when `boxes` is not a
          floating point tensor. True to raise an error when `boxes` isn't a floating point tensor, False
          to cast to float.
      mode: the box format of the input boxes.
  
  Note:
      **2D boxes format** is defined as a floating data type tensor of shape ``Nx4x2`` or ``BxNx4x2``
      where each box is a `quadrilateral <https://en.wikipedia.org/wiki/Quadrilateral>`_ defined by it's
      4 vertices coordinates (A, B, C, D). Coordinates must be in ``x, y`` order. The height and width of
      a box is defined as ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``. Examples of
      `quadrilaterals <https://en.wikipedia.org/wiki/Quadrilateral>`_ are rectangles, rhombus and trapezoids.
class_docstr_tok: ["2D","boxes","containing","N","or","BxN","boxes",".","Args",":","boxes",":","2D","boxes",",","shape","of",":","math",":","`","(","N",",","4",",","2",")","`",",",":","math",":","`","(","B",",","N",",","4",",","2",")","`","or","a","list","of",":","math",":","`","(","N",",","4",",","2",")","`",".","See","below","for","more","details",".","raise_if_not_floating_point",":","flag","to","control","floating","point","casting","behaviour","when","`","boxes","`","is","not","a","floating","point","tensor",".","True","to","raise","an","error","when","`","boxes","`","is","n't","a","floating","point","tensor",",","False","to","cast","to","float",".","mode",":","the","box","format","of","the","input","boxes",".","Note",":","*","*","2D","boxes","format","*","*","is","defined","as","a","floating","data","type","tensor","of","shape","``","Nx4x2","``","or","``","BxNx4x2","``","where","each","box","is","a","`","quadrilateral","<","https",":","\/\/en.wikipedia.org\/wiki\/Quadrilateral",">","`","_","defined","by","it's","4","vertices","coordinates","(","A",",","B",",","C",",","D",")",".","Coordinates","must","be","in","``","x",",","y","``","order",".","The","height","and","width","of","a","box","is","defined","as","``","width","=","xmax","-","xmin","+","1","``","and","``","height","=","ymax","-","ymin","+","1","``",".","Examples","of","`","quadrilaterals","<","https",":","\/\/en.wikipedia.org\/wiki\/Quadrilateral",">","`","_","are","rectangles",",","rhombus","and","trapezoids","."]
docstr: Convert 2D boxes to masks. Covered area is 1 and the remaining is 0.
  
  Args:
      height: height of the masked image/images.
      width: width of the masked image/images.
  
  Returns:
      the output mask tensor, shape of :math:`(N, width, height)` or :math:`(B,N, width, height)` and dtype of
      :func:`Boxes.dtype` (it can be any floating point dtype).
  
  Note:
      It is currently non-differentiable.
  
  Examples:
      >>> boxes = Boxes(torch.tensor([[  # Equivalent to boxes = Boxes.from_tensor([[1,1,4,3]])
      ...        [1., 1.],
      ...        [4., 1.],
      ...        [4., 3.],
      ...        [1., 3.],
      ...   ]]))  # 1x4x2
      >>> boxes.to_mask(5, 5)
      tensor([[[0., 0., 0., 0., 0.],
               [0., 1., 1., 1., 1.],
               [0., 1., 1., 1., 1.],
               [0., 1., 1., 1., 1.],
               [0., 0., 0., 0., 0.]]])
code: def to_mask(self, height: int, width: int) -> torch.Tensor:
      """Convert 2D boxes to masks. Covered area is 1 and the remaining is 0.
  
      Args:
          height: height of the masked image/images.
          width: width of the masked image/images.
  
      Returns:
          the output mask tensor, shape of :math:`(N, width, height)` or :math:`(B,N, width, height)` and dtype of
          :func:`Boxes.dtype` (it can be any floating point dtype).
  
      Note:
          It is currently non-differentiable.
  
      Examples:
          >>> boxes = Boxes(torch.tensor([[  # Equivalent to boxes = Boxes.from_tensor([[1,1,4,3]])
          ...        [1., 1.],
          ...        [4., 1.],
          ...        [4., 3.],
          ...        [1., 3.],
          ...   ]]))  # 1x4x2
          >>> boxes.to_mask(5, 5)
          tensor([[[0., 0., 0., 0., 0.],
                   [0., 1., 1., 1., 1.],
                   [0., 1., 1., 1., 1.],
                   [0., 1., 1., 1., 1.],
                   [0., 0., 0., 0., 0.]]])
      """
      if self._data.requires_grad:
          raise RuntimeError(
              "Boxes.to_tensor isn't differentiable. Please, create boxes from tensors with `requires_grad=False`."
          )
  
      if self._is_batched:  # (B, N, 4, 2)
          mask = torch.zeros(
              (self._data.shape[0], self._data.shape[1], height, width),
              dtype=self.dtype,
              device=self.device,
          )
      else:  # (N, 4, 2)
          mask = zeros(
              (self._data.shape[0], height, width),
              dtype=self.dtype,
              device=self.device,
          )
  
      # Boxes coordinates can be outside the image size after transforms. Clamp values to the image size
      clipped_boxes_xyxy = cast(
          torch.Tensor, self.to_tensor("xyxy", as_padded_sequence=True)
      )
      clipped_boxes_xyxy[..., ::2].clamp_(0, width)
      clipped_boxes_xyxy[..., 1::2].clamp_(0, height)
  
      # Reshape mask to (BxN, H, W) and boxes to (BxN, 4) to iterate over all of them.
      # Cast boxes coordinates to be integer to use them as indexes. Use round to handle decimal values.
      for mask_channel, box_xyxy in zip(
          mask.view(-1, height, width),
          clipped_boxes_xyxy.view(-1, 4).round().int(),
      ):
          # Mask channel dimensions: (height, width)
          mask_channel[
              box_xyxy[1] : box_xyxy[3], box_xyxy[0] : box_xyxy[2]
          ] = 1
  
      return mask
  
imports: from __future__ import annotations
  from typing import Optional, cast
  import torch
  from torch import Size
  from kornia.core import Tensor, stack, zeros
  from kornia.geometry.bbox import validate_bbox
  from kornia.geometry.linalg import transform_points
  from kornia.utils import eye_like
label_desc: Use image node_id 16 for calling the Boxes obj's underlying member method code with example usage: obj.to_mask(height, width) and returns: mask