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 _prepare_sample(
      self,
      data: Tuple[
          Tuple[Any, Tuple[str, BinaryIO]], Tuple[str, BinaryIO]
      ],
  ) -> Dict[str, Any]:
      split_and_image_data, ann_data = data
      _, image_data = split_and_image_data
      image_path, image_buffer = image_data
      ann_path, ann_buffer = ann_data
  
      anns = read_mat(ann_buffer, squeeze_me=True)["GTcls"]
  
      return dict(
          image_path=image_path,
          image=EncodedImage.from_file(image_buffer),
          ann_path=ann_path,
          # the boundaries are stored in sparse CSC format, which is not supported by PyTorch
          boundaries=torch.as_tensor(
              np.stack(
                  [
                      raw_boundary.toarray()
                      for raw_boundary in anns["Boundaries"].item()
                  ]
              )
          ),
          segmentation=torch.as_tensor(anns["Segmentation"].item()),
      )
  
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 4 for calling the SBD obj's underlying member method code with example usage: obj._prepare_sample(data) and returns: dict