class_docstr: Base class for the MS COCO Object Detection Dataset. Sub-classes should implement
  training and validation transform functions.
  
  Args:
      opts: command-line arguments
  
  .. note::
      This class implements basic functions (e.g., reading image and annotations), and does not implement
      training/validation transforms. Detector specific sub-classes should extend this class and implement those
      methods. See `coco_ssd.py` as an example for SSD.
class_docstr_tok: ["Base","class","for","the","MS","COCO","Object","Detection","Dataset",".","Sub-classes","should","implement","training","and","validation","transform","functions",".","Args",":","opts",":","command-line","arguments","..","note",":",":","This","class","implements","basic","functions","(","e.g.",",","reading","image","and","annotations",")",",","and","does","not","implement","training\/validation","transforms",".","Detector","specific","sub-classes","should","extend","this","class","and","implement","those","methods",".","See","`","coco_ssd.py","`","as","an","example","for","SSD","."]
docstr: Get the boxes and label information for a given image_id
  
  Args:
      image_id: Image ID
      image_width: Width of the image
      image_height: Height of the image
      include_masks: Return instance masks or not
  
  Returns:
      A tuple of length 3:
          * Numpy array containing bounding box information in xyxy format.
              The shape of array is [Num_of_boxes, 4].
          * Numpy array containing labels for each of the box. The shape of array is [Num_of_boxes]
          * When include_masks is enabled, a numpy array of instance masks is returned. The shape of the
              array is [Num_of_boxes, image_height, image_width]
docstr_tok: ["Get","the","boxes","and","label","information","for","a","given","image_id","Args",":","image_id",":","Image","ID","image_width",":","Width","of","the","image","image_height",":","Height","of","the","image","include_masks",":","Return","instance","masks","or","not","Returns",":","A","tuple","of","length","3",":","*","Numpy","array","containing","bounding","box","information","in","xyxy","format",".","The","shape","of","array","is","[","Num_of_boxes",",","4","]",".","*","Numpy","array","containing","labels","for","each","of","the","box",".","The","shape","of","array","is","[","Num_of_boxes","]","*","When","include_masks","is","enabled",",","a","numpy","array","of","instance","masks","is","returned",".","The","shape","of","the","array","is","[","Num_of_boxes",",","image_height",",","image_width","]"]
code: def get_boxes_and_labels(
      self,
      image_id: int,
      image_width: int,
      image_height: int,
      *args,
      include_masks=False,
      **kwargs,
  ) -> Tuple[np.ndarray, np.ndarray, Optional[np.ndarray]]:
      """Get the boxes and label information for a given image_id
  
      Args:
          image_id: Image ID
          image_width: Width of the image
          image_height: Height of the image
          include_masks: Return instance masks or not
  
      Returns:
          A tuple of length 3:
              * Numpy array containing bounding box information in xyxy format.
                  The shape of array is [Num_of_boxes, 4].
              * Numpy array containing labels for each of the box. The shape of array is [Num_of_boxes]
              * When include_masks is enabled, a numpy array of instance masks is returned. The shape of the
                  array is [Num_of_boxes, image_height, image_width]
  
      """
      ann_ids = self.coco.getAnnIds(imgIds=image_id)
      ann = self.coco.loadAnns(ann_ids)
  
      # filter crowd annotations
      ann = [obj for obj in ann if obj["iscrowd"] == 0]
      boxes = np.array(
          [
              self._xywh2xyxy(obj["bbox"], image_width, image_height)
              for obj in ann
          ],
          np.float32,
      ).reshape((-1, 4))
      labels = np.array(
          [
              self.coco_id_to_contiguous_id[obj["category_id"]]
              for obj in ann
          ],
          np.int64,
      ).reshape((-1,))
      # remove invalid boxes
      keep = (boxes[:, 3] > boxes[:, 1]) & (boxes[:, 2] > boxes[:, 0])
      boxes = boxes[keep]
      labels = labels[keep]
  
      masks = None
      if include_masks:
          masks = []
          for obj in ann:
              rle = coco_mask.frPyObjects(
                  obj["segmentation"], image_height, image_width
              )
              m = coco_mask.decode(rle)
              if len(m.shape) < 3:
                  mask = m.astype(np.uint8)
              else:
                  mask = (np.sum(m, axis=2) > 0).astype(np.uint8)
              masks.append(mask)
  
          if len(masks) > 0:
              masks = np.stack(masks, axis=0)
          else:
              masks = np.zeros(
                  shape=(0, image_height, image_width), dtype=np.uint8
              )
          masks = masks.astype(np.uint8)
          masks = torch.from_numpy(masks)
          masks = masks[keep]
          assert len(boxes) == len(labels) == len(masks)
          return boxes, labels, masks
      else:
          return boxes, labels, None
  
imports: import argparse
  import os
  from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
  import numpy
  import torch
  from pycocotools import mask
  from pycocotools.coco import COCO
  from torch import Tensor
  from data.datasets import DATASET_REGISTRY
  from data.datasets.detection.base_detection import BaseDetectionDataset
  from data.transforms import image_pil
  from data.transforms.common import Compose
  from utils import logger
label_desc: Use image node_id 7 for calling the COCODetection obj's underlying member method code with example usage: obj.get_boxes_and_labels(image_id, image_width, image_height) and returns: boxes,  labels,  masks, boxes,  labels,  None