class_docstr: 3D boxes containing N or BxN boxes.
  
  Args:
      boxes: 3D boxes, shape of :math:`(N,8,3)` or :math:`(B,N,8,3)`. 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.
  
  Note:
      **3D boxes format** is defined as a floating data type tensor of shape ``Nx8x3`` or ``BxNx8x3`` where each box
      is a `hexahedron <https://en.wikipedia.org/wiki/Hexahedron>`_ defined by it's 8 vertices coordinates.
      Coordinates must be in ``x, y, z`` order. The height, width and depth of a box is defined as
      ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``. Examples of
      `hexahedrons <https://en.wikipedia.org/wiki/Hexahedron>`_ are cubes and rhombohedrons.
class_docstr_tok: ["3D","boxes","containing","N","or","BxN","boxes",".","Args",":","boxes",":","3D","boxes",",","shape","of",":","math",":","`","(","N,8,3",")","`","or",":","math",":","`","(","B",",","N,8,3",")","`",".","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",".","Note",":","*","*","3D","boxes","format","*","*","is","defined","as","a","floating","data","type","tensor","of","shape","``","Nx8x3","``","or","``","BxNx8x3","``","where","each","box","is","a","`","hexahedron","<","https",":","\/\/en.wikipedia.org\/wiki\/Hexahedron",">","`","_","defined","by","it","'s","8","vertices","coordinates",".","Coordinates","must","be","in","``","x",",","y",",","z","``","order",".","The","height",",","width","and","depth","of","a","box","is","defined","as","``","width","=","xmax","-","xmin","+","1","``",",","``","height","=","ymax","-","ymin","+","1","``","and","``","depth","=","zmax","-","zmin","+","1","``",".","Examples","of","`","hexahedrons","<","https",":","\/\/en.wikipedia.org\/wiki\/Hexahedron",">","`","_","are","cubes","and","rhombohedrons","."]
docstr: Convert ·D boxes to masks. Covered area is 1 and the remaining is 0.
  
  Args:
      depth: depth of the masked image/images.
      height: height of the masked image/images.
      width: width of the masked image/images.
  
  Returns:
      the output mask tensor, shape of :math:`(N, depth, width, height)` or :math:`(B,N, depth, width, height)`
       and dtype of :func:`Boxes3D.dtype` (it can be any floating point dtype).
  
  Note:
      It is currently non-differentiable.
  
  Examples:
      >>> boxes = Boxes3D(torch.tensor([[  # Equivalent to boxes = Boxes.3Dfrom_tensor([[1,1,1,3,3,2]])
      ...     [1., 1., 1.],
      ...     [3., 1., 1.],
      ...     [3., 3., 1.],
      ...     [1., 3., 1.],
      ...     [1., 1., 2.],
      ...     [3., 1., 2.],
      ...     [3., 3., 2.],
      ...     [1., 3., 2.],
      ... ]]))  # 1x8x3
      >>> boxes.to_mask(4, 5, 5)
      tensor([[[[0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.]],
      <BLANKLINE>
               [[0., 0., 0., 0., 0.],
                [0., 1., 1., 1., 0.],
                [0., 1., 1., 1., 0.],
                [0., 1., 1., 1., 0.],
                [0., 0., 0., 0., 0.]],
      <BLANKLINE>
               [[0., 0., 0., 0., 0.],
                [0., 1., 1., 1., 0.],
                [0., 1., 1., 1., 0.],
                [0., 1., 1., 1., 0.],
                [0., 0., 0., 0., 0.]],
      <BLANKLINE>
               [[0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.],
                [0., 0., 0., 0., 0.]]]])
code: def to_mask(
      self, depth: int, height: int, width: int
  ) -> torch.Tensor:
      """Convert ·D boxes to masks. Covered area is 1 and the remaining is 0.
  
      Args:
          depth: depth of the masked image/images.
          height: height of the masked image/images.
          width: width of the masked image/images.
  
      Returns:
          the output mask tensor, shape of :math:`(N, depth, width, height)` or :math:`(B,N, depth, width, height)`
           and dtype of :func:`Boxes3D.dtype` (it can be any floating point dtype).
  
      Note:
          It is currently non-differentiable.
  
      Examples:
          >>> boxes = Boxes3D(torch.tensor([[  # Equivalent to boxes = Boxes.3Dfrom_tensor([[1,1,1,3,3,2]])
          ...     [1., 1., 1.],
          ...     [3., 1., 1.],
          ...     [3., 3., 1.],
          ...     [1., 3., 1.],
          ...     [1., 1., 2.],
          ...     [3., 1., 2.],
          ...     [3., 3., 2.],
          ...     [1., 3., 2.],
          ... ]]))  # 1x8x3
          >>> boxes.to_mask(4, 5, 5)
          tensor([[[[0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.]],
          <BLANKLINE>
                   [[0., 0., 0., 0., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 0., 0., 0., 0.]],
          <BLANKLINE>
                   [[0., 0., 0., 0., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 1., 1., 1., 0.],
                    [0., 0., 0., 0., 0.]],
          <BLANKLINE>
                   [[0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.],
                    [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, 8, 3)
          mask = zeros(
              (
                  self._data.shape[0],
                  self._data.shape[1],
                  depth,
                  height,
                  width,
              ),
              dtype=self._data.dtype,
              device=self._data.device,
          )
      else:  # (N, 8, 3)
          mask = zeros(
              (self._data.shape[0], depth, height, width),
              dtype=self._data.dtype,
              device=self._data.device,
          )
  
      # Boxes coordinates can be outside the image size after transforms. Clamp values to the image size
      clipped_boxes_xyzxyz = self.to_tensor("xyzxyz")
      clipped_boxes_xyzxyz[..., ::3].clamp_(0, width)
      clipped_boxes_xyzxyz[..., 1::3].clamp_(0, height)
      clipped_boxes_xyzxyz[..., 2::3].clamp_(0, depth)
  
      # Reshape mask to (BxN, D, H, W) and boxes to (BxN, 6) 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_xyzxyz in zip(
          mask.view(-1, depth, height, width),
          clipped_boxes_xyzxyz.view(-1, 6).round().int(),
      ):
          # Mask channel dimensions: (depth, height, width)
          mask_channel[
              box_xyzxyz[2] : box_xyzxyz[5],
              box_xyzxyz[1] : box_xyzxyz[4],
              box_xyzxyz[0] : box_xyzxyz[3],
          ] = 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 8 for calling the Boxes3D obj's underlying member method code with example usage: obj.to_mask(depth, height, width) and returns: mask