class_docstr: Accumulates annotations by batches that correspond to objects detected on
  individual images. Can pack them together into single tensors.
class_docstr_tok: ["Accumulates","annotations","by","batches","that","correspond","to","objects","detected","on","individual","images",".","Can","pack","them","together","into","single","tensors","."]
docstr: Pack data into tensors
docstr_tok: ["Pack","data","into","tensors"]
code: def pack(self) -> Optional[PackedChartBasedAnnotations]:
      """
      Pack data into tensors
      """
      if not len(self.i_gt):
          # TODO:
          # returning proper empty annotations would require
          # creating empty tensors of appropriate shape and
          # type on an appropriate device;
          # we return None so far to indicate empty annotations
          return None
      return PackedChartBasedAnnotations(
          fine_segm_labels_gt=torch.cat(self.i_gt, 0).long(),
          x_gt=torch.cat(self.x_gt, 0),
          y_gt=torch.cat(self.y_gt, 0),
          u_gt=torch.cat(self.u_gt, 0),
          v_gt=torch.cat(self.v_gt, 0),
          # ignore segmentation annotations, if not all the instances contain those
          coarse_segm_gt=torch.cat(self.s_gt, 0)
          if len(self.s_gt) == len(self.bbox_xywh_gt)
          else None,
          bbox_xywh_gt=torch.cat(self.bbox_xywh_gt, 0),
          bbox_xywh_est=torch.cat(self.bbox_xywh_est, 0),
          point_bbox_with_dp_indices=torch.cat(
              self.point_bbox_with_dp_indices, 0
          ).long(),
          point_bbox_indices=torch.cat(
              self.point_bbox_indices, 0
          ).long(),
          bbox_indices=torch.as_tensor(
              self.bbox_indices,
              dtype=torch.long,
              device=self.x_gt[0].device,
          ).long(),
      )
  
imports: from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  from torch.nn import functional
  from detectron2.structures import BoxMode, Instances
  from densepose import DensePoseDataRelative
label_desc: Use image node_id 4 for calling the ChartBasedAnnotationsAccumulator obj's underlying member method code with example usage: obj.pack() and returns: PackedChartBasedAnnotations, None