class_docstr: :class:`torch.Tensor` subclass for bounding boxes.
  
  .. note::
      There should be only one :class:`~torchvision.tv_tensors.BoundingBoxes`
      instance per sample e.g. ``{"img": img, "bbox": BoundingBoxes(...)}``,
      although one :class:`~torchvision.tv_tensors.BoundingBoxes` object can
      contain multiple bounding boxes.
  
  Args:
      data: Any data that can be turned into a tensor with :func:`torch.as_tensor`.
      format (BoundingBoxFormat, str): Format of the bounding box.
      canvas_size (two-tuple of ints): Height and width of the corresponding image or video.
      dtype (torch.dtype, optional): Desired data type of the bounding box. If omitted, will be inferred from
          ``data``.
      device (torch.device, optional): Desired device of the bounding box. If omitted and ``data`` is a
          :class:`torch.Tensor`, the device is taken from it. Otherwise, the bounding box is constructed on the CPU.
      requires_grad (bool, optional): Whether autograd should record operations on the bounding box. If omitted and
          ``data`` is a :class:`torch.Tensor`, the value is taken from it. Otherwise, defaults to ``False``.
code: def _wrap_output(
      cls,
      output: torch.Tensor,
      args: Sequence[Any] = (),
      kwargs: Optional[Mapping[str, Any]] = None,
  ) -> BoundingBoxes:
      # If there are BoundingBoxes instances in the output, their metadata got lost when we called
      # super().__torch_function__. We need to restore the metadata somehow, so we choose to take
      # the metadata from the first bbox in the parameters.
      # This should be what we want in most cases. When it's not, it's probably a mis-use anyway, e.g.
      # something like some_xyxy_bbox + some_xywh_bbox; we don't guard against those cases.
      flat_params, _ = tree_flatten(args + (tuple(kwargs.values()) if kwargs else ()))  # type: ignore[operator]
      first_bbox_from_args = next(
          x for x in flat_params if isinstance(x, BoundingBoxes)
      )
      format, canvas_size = (
          first_bbox_from_args.format,
          first_bbox_from_args.canvas_size,
      )
  
      if isinstance(output, torch.Tensor) and not isinstance(
          output, BoundingBoxes
      ):
          output = BoundingBoxes._wrap(
              output,
              format=format,
              canvas_size=canvas_size,
              check_dims=False,
          )
      elif isinstance(output, (tuple, list)):
          output = type(output)(
              BoundingBoxes._wrap(
                  part,
                  format=format,
                  canvas_size=canvas_size,
                  check_dims=False,
              )
              for part in output
          )
      return output
  
file_path: vision/torchvision/tv_tensors/_bounding_boxes.py
imports: from __future__ import annotations
  from enum import Enum
  from typing import Any, Mapping, Optional, Sequence, Tuple, Union
  import torch
  from torch.utils._pytree import tree_flatten
  from ._tv_tensor import TVTensor
label_desc: Use image node_id 3 for calling the BoundingBoxes obj's underlying member method code with example usage: obj._wrap_output(cls, output, args, kwargs) and returns: output