code: def unpack_gt_instances(batch_data_samples: SampleList) -> tuple:
      """Unpack ``gt_instances``, ``gt_instances_ignore`` and ``img_metas`` based
      on ``batch_data_samples``
  
      Args:
          batch_data_samples (List[:obj:`DetDataSample`]): The Data
              Samples. It usually includes information such as
              `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
  
      Returns:
          tuple:
  
              - batch_gt_instances (list[:obj:`InstanceData`]): Batch of
                  gt_instance. It usually includes ``bboxes`` and ``labels``
                  attributes.
              - batch_gt_instances_ignore (list[:obj:`InstanceData`]):
                  Batch of gt_instances_ignore. It includes ``bboxes`` attribute
                  data that is ignored during training and testing.
                  Defaults to None.
              - batch_img_metas (list[dict]): Meta information of each image,
                  e.g., image size, scaling factor, etc.
      """
      batch_gt_instances = []
      batch_gt_instances_ignore = []
      batch_img_metas = []
      for data_sample in batch_data_samples:
          batch_img_metas.append(data_sample.metainfo)
          batch_gt_instances.append(data_sample.gt_instances)
          if "ignored_instances" in data_sample:
              batch_gt_instances_ignore.append(
                  data_sample.ignored_instances
              )
          else:
              batch_gt_instances_ignore.append(None)
  
      return (
          batch_gt_instances,
          batch_gt_instances_ignore,
          batch_img_metas,
      )
  
imports: from functools import partial
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from mmengine.utils import digit_version
  from six.moves import map, zip
  from torch import Tensor
  from torch.autograd import Function
  from torch.nn import functional
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import BaseBoxes, get_box_type, stack_boxes
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
  from mmdet.utils import OptInstanceList
label_desc: Use image node_id 2 for calling a global function with example usage: unpack_gt_instances(batch_data_samples) and returns: batch_gt_instances,  batch_gt_instances_ignore,  batch_img_metas