class_docstr: - **homepage**: http://home.bharathh.info/pubs/codes/SBD/download.html
  - **dependencies**:
      - <scipy `https://scipy.org`>_
class_docstr_tok: ["-","*","*","homepage","*","*",":","http",":","\/\/home.bharathh.info\/pubs\/codes\/SBD\/download.html","-","*","*","dependencies","*","*",":","-","<","scipy","`","https",":","\/\/scipy.org","`",">","_"]
code: def _generate_categories(self) -> Tuple[str, ...]:
      resources = self._resources()
  
      dp = resources[0].load(self._root)
      dp = Filter(dp, path_comparator("name", "category_names.m"))
      dp = LineReader(dp)
      dp = Mapper(dp, bytes.decode, input_col=1)
      lines = tuple(zip(*iter(dp)))[1]
  
      pattern = re.compile(r"\s*'(?P<category>\w+)';\s*%(?P<label>\d+)")
      categories_and_labels = cast(
          List[Tuple[str, ...]],
          [
              pattern.match(line).groups()  # type: ignore[union-attr]
              # the first and last line contain no information
              for line in lines[1:-1]
          ],
      )
      categories_and_labels.sort(
          key=lambda category_and_label: int(category_and_label[1])
      )
      categories, _ = zip(*categories_and_labels)
  
      return categories
  
file_path: vision/torchvision/prototype/datasets/_builtin/sbd.py
imports: import pathlib
  import re
  from typing import Any, BinaryIO, cast, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torchdata.datapipes.iter import Demultiplexer, Filter, IterDataPipe, IterKeyZipper, LineReader, Mapper
  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, path_accessor, path_comparator, read_categories_file, read_mat
  from .._api import register_dataset, register_info
label_desc: Use image node_id 7 for calling the SBD obj's underlying member method code with example usage: obj._generate_categories() and returns: categories