class_docstr: - **homepage**: https://www.westernsydney.edu.au/icns/reproducible_research/publication_support_materials/emnist
class_docstr_tok: ["-","*","*","homepage","*","*",":","https",":","\/\/www.westernsydney.edu.au\/icns\/reproducible_research\/publication_support_materials\/emnist"]
code: def _prepare_sample(
      self, data: Tuple[torch.Tensor, torch.Tensor]
  ) -> Dict[str, Any]:
      # In these two splits, some lowercase letters are merged into their uppercase ones (see Fig 2. in the paper).
      # That means for example that there is 'D', 'd', and 'C', but not 'c'. Since the labels are nevertheless dense,
      # i.e. no gaps between 0 and 46 for 47 total classes, we need to add an offset to create these gaps. For
      # example, since there is no 'c', 'd' corresponds to
      # label 38 (10 digits + 26 uppercase letters + 3rd unmerged lower case letter - 1 for zero indexing),
      # and at the same time corresponds to
      # index 39 (10 digits + 26 uppercase letters + 4th lower case letter - 1 for zero indexing)
      # in self._categories. Thus, we need to add 1 to the label to correct this.
      if self._image_set in ("Balanced", "By_Merge"):
          image, label = data
          label += self._LABEL_OFFSETS.get(int(label), 0)
          data = (image, label)
      return super()._prepare_sample(data)
  
imports: import abc
  import functools
  import operator
  import pathlib
  import string
  from typing import Any, BinaryIO, cast, Dict, Iterator, List, Optional, Sequence, Tuple, Union
  import torch
  from torchdata.datapipes.iter import Decompressor, Demultiplexer, IterDataPipe, Mapper, Zipper
  from torchvision.prototype.datasets.utils import Dataset, HttpResource, OnlineResource
  from torchvision.prototype.datasets.utils._internal import hint_sharding, hint_shuffling, INFINITE_BUFFER_SIZE
  from torchvision.prototype.tv_tensors import Label
  from torchvision.prototype.utils._internal import fromfile
  from torchvision.tv_tensors import Image
  from .._api import register_dataset, register_info
label_desc: Use image node_id 5 for calling the EMNIST obj's underlying member method code with example usage: obj._prepare_sample(data) and returns: super