class_docstr: - **homepage**: https://www.image-net.org/
class_docstr_tok: ["-","*","*","homepage","*","*",":","https",":","\/\/www.image-net.org\/"]
code: def _datapipe(
      self, resource_dps: List[IterDataPipe]
  ) -> IterDataPipe[Dict[str, Any]]:
      if self._split in {"train", "test"}:
          dp = resource_dps[0]
  
          # the train archive is a tar of tars
          if self._split == "train":
              dp = TarArchiveLoader(dp)
  
          dp = hint_shuffling(dp)
          dp = hint_sharding(dp)
          dp = Mapper(
              dp,
              self._prepare_train_data
              if self._split == "train"
              else self._prepare_test_data,
          )
      else:  # config.split == "val":
          images_dp, devkit_dp = resource_dps
  
          meta_dp, label_dp = Demultiplexer(
              devkit_dp,
              2,
              self._classifiy_devkit,
              drop_none=True,
              buffer_size=INFINITE_BUFFER_SIZE,
          )
  
          # We cannot use self._wnids here, since we use a different order than the dataset
          meta_dp = CategoryAndWordNetIDExtractor(meta_dp)
          wnid_dp = Mapper(meta_dp, getitem(1))
          wnid_dp = Enumerator(wnid_dp, 1)
          wnid_map = IterToMapConverter(wnid_dp)
  
          label_dp = LineReader(
              label_dp, decode=True, return_path=False
          )
          label_dp = Mapper(label_dp, int)
          label_dp = Mapper(label_dp, wnid_map.__getitem__)
          label_dp: IterDataPipe[Tuple[int, str]] = Enumerator(
              label_dp, 1
          )
          label_dp = hint_shuffling(label_dp)
          label_dp = hint_sharding(label_dp)
  
          dp = IterKeyZipper(
              label_dp,
              images_dp,
              key_fn=getitem(0),
              ref_key_fn=path_accessor(self._val_test_image_key),
              buffer_size=INFINITE_BUFFER_SIZE,
          )
          dp = Mapper(dp, self._prepare_val_data)
  
      return Mapper(dp, self._prepare_sample)
  
imports: import enum
  import pathlib
  import re
  from typing import Any, BinaryIO, cast, Dict, Iterator, List, Match, Optional, Tuple, Union
  from torchdata.datapipes.iter import Demultiplexer, Enumerator, Filter, IterDataPipe, IterKeyZipper, LineReader, Mapper, TarArchiveLoader
  from torchdata.datapipes.map import IterToMapConverter
  from torchvision.prototype.datasets.utils import Dataset, EncodedImage, ManualDownloadResource, OnlineResource
  from torchvision.prototype.datasets.utils._internal import getitem, hint_sharding, hint_shuffling, INFINITE_BUFFER_SIZE, path_accessor, read_categories_file, read_mat
  from torchvision.prototype.tv_tensors import Label
  from .._api import register_dataset, register_info
label_desc: Use image node_id 9 for calling the ImageNet obj's underlying member method code with example usage: obj._datapipe(resource_dps) and returns: Mapper