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: Helper method to easily create :class:`Boxes3D` from 3D boxes stored in another format.
  
  Args:
      boxes: 3D boxes, shape of :math:`(N,6)` or :math:`(B,N,6)`.
      mode: The format in which the 3D boxes are provided.
  
          * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
            ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
          * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
            ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
          * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
            ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
  
      validate_boxes: check if boxes are valid rectangles or not. Valid rectangles are those with width, height
          and depth >= 1 (>= 2 when mode ends with '_plus' suffix).
  
  Returns:
      :class:`Boxes3D` class containing the original `boxes` in the format specified by ``mode``.
  
  Examples:
      >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
      >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
      >>> boxes.data  # (2, 8, 3)
      tensor([[[0., 3., 6.],
               [0., 3., 6.],
               [0., 3., 6.],
               [0., 3., 6.],
               [0., 3., 7.],
               [0., 3., 7.],
               [0., 3., 7.],
               [0., 3., 7.]],
      <BLANKLINE>
              [[5., 1., 3.],
               [7., 1., 3.],
               [7., 3., 3.],
               [5., 3., 3.],
               [5., 1., 8.],
               [7., 1., 8.],
               [7., 3., 8.],
               [5., 3., 8.]]])
code: def from_tensor(
      cls,
      boxes: torch.Tensor,
      mode: str = "xyzxyz",
      validate_boxes: bool = True,
  ) -> Boxes3D:
      r"""Helper method to easily create :class:`Boxes3D` from 3D boxes stored in another format.
  
      Args:
          boxes: 3D boxes, shape of :math:`(N,6)` or :math:`(B,N,6)`.
          mode: The format in which the 3D boxes are provided.
  
              * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
                ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
              * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
                ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
              * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
                ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
  
          validate_boxes: check if boxes are valid rectangles or not. Valid rectangles are those with width, height
              and depth >= 1 (>= 2 when mode ends with '_plus' suffix).
  
      Returns:
          :class:`Boxes3D` class containing the original `boxes` in the format specified by ``mode``.
  
      Examples:
          >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
          >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
          >>> boxes.data  # (2, 8, 3)
          tensor([[[0., 3., 6.],
                   [0., 3., 6.],
                   [0., 3., 6.],
                   [0., 3., 6.],
                   [0., 3., 7.],
                   [0., 3., 7.],
                   [0., 3., 7.],
                   [0., 3., 7.]],
          <BLANKLINE>
                  [[5., 1., 3.],
                   [7., 1., 3.],
                   [7., 3., 3.],
                   [5., 3., 3.],
                   [5., 1., 8.],
                   [7., 1., 8.],
                   [7., 3., 8.],
                   [5., 3., 8.]]])
      """
      if not (2 <= boxes.ndim <= 3 and boxes.shape[-1] == 6):
          raise ValueError(
              f"BBox shape must be (N, 6) or (B, N, 6). Got {boxes.shape}."
          )
  
      batched = boxes.ndim == 3
      boxes = boxes if batched else boxes.unsqueeze(0)
      boxes = boxes if boxes.is_floating_point() else boxes.float()
  
      xmin, ymin, zmin = boxes[..., 0], boxes[..., 1], boxes[..., 2]
      mode = mode.lower()
      if mode == "xyzxyz":
          width = boxes[..., 3] - boxes[..., 0]
          height = boxes[..., 4] - boxes[..., 1]
          depth = boxes[..., 5] - boxes[..., 2]
      elif mode == "xyzxyz_plus":
          width = boxes[..., 3] - boxes[..., 0] + 1
          height = boxes[..., 4] - boxes[..., 1] + 1
          depth = boxes[..., 5] - boxes[..., 2] + 1
      elif mode == "xyzwhd":
          depth, height, width = (
              boxes[..., 4],
              boxes[..., 3],
              boxes[..., 5],
          )
      else:
          raise ValueError(f"Unknown mode {mode}")
  
      if validate_boxes:
          if (width <= 0).any():
              raise ValueError("Some boxes have negative widths or 0.")
          if (height <= 0).any():
              raise ValueError("Some boxes have negative heights or 0.")
          if (depth <= 0).any():
              raise ValueError("Some boxes have negative depths or 0.")
  
      hexahedrons = _boxes3d_to_polygons3d(
          xmin, ymin, zmin, width, height, depth
      )
      hexahedrons = hexahedrons if batched else hexahedrons.squeeze(0)
      return cls(
          hexahedrons, raise_if_not_floating_point=False, mode=mode
      )
  
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 6 for calling the Boxes3D obj's underlying member method code with example usage: obj.from_tensor(cls, boxes, mode, validate_boxes) and returns: cls