class_docstr: - **homepage**: https://cocodataset.org/
  - **dependencies**:
      - <pycocotools `https://github.com/cocodataset/cocoapi`>_
class_docstr_tok: ["-","*","*","homepage","*","*",":","https",":","\/\/cocodataset.org\/","-","*","*","dependencies","*","*",":","-","<","pycocotools","`","https",":","\/\/github.com\/cocodataset\/cocoapi","`",">","_"]
code: def _generate_categories(self) -> Tuple[Tuple[str, str]]:
      self._annotations = "instances"
      resources = self._resources()
  
      dp = resources[1].load(self._root)
      dp = Filter(dp, self._filter_meta_files)
      dp = JsonParser(dp)
  
      _, meta = next(iter(dp))
      # List[Tuple[super_category, id, category]]
      label_data = [
          cast(Tuple[str, int, str], tuple(info.values()))
          for info in meta["categories"]
      ]
  
      # COCO actually defines 91 categories, but only 80 of them have instances. Still, the category_id refers to the
      # full set. To keep the labels dense, we fill the gaps with N/A. Note that there are only 10 gaps, so the total
      # number of categories is 90 rather than 91.
      _, ids, _ = zip(*label_data)
      missing_ids = set(range(1, max(ids) + 1)) - set(ids)
      label_data.extend([("N/A", id, "N/A") for id in missing_ids])
  
      # We also add a background category to be used during segmentation.
      label_data.append(("N/A", 0, "__background__"))
  
      super_categories, _, categories = zip(
          *sorted(label_data, key=lambda info: info[1])
      )
  
      return cast(
          Tuple[Tuple[str, str]],
          tuple(zip(categories, super_categories)),
      )
  
imports: import pathlib
  import re
  from collections import defaultdict, OrderedDict
  from typing import Any, BinaryIO, cast, Dict, List, Optional, Tuple, Union
  import torch
  from torchdata.datapipes.iter import Demultiplexer, Filter, Grouper, IterDataPipe, IterKeyZipper, JsonParser, Mapper, UnBatcher
  from torchvision.prototype.datasets.utils import Dataset, EncodedImage, HttpResource, OnlineResource
  from torchvision.prototype.datasets.utils._internal import getitem, hint_sharding, hint_shuffling, INFINITE_BUFFER_SIZE, MappingIterator, path_accessor, read_categories_file
  from torchvision.prototype.tv_tensors import Label
  from torchvision.tv_tensors import BoundingBoxes, Mask
  from .._api import register_dataset, register_info
label_desc: Use image node_id 12 for calling the Coco obj's underlying member method code with example usage: obj._generate_categories() and returns: cast