docstr_tok: []
code: def __init__(
      self,
      name: str,
      root: Optional[str] = None,
      split: str = "train",
      class_map: dict = None,
      image_key: str = "image",
      target_key: str = "label",
      download: bool = False,
  ):
      """ """
      super().__init__()
      self.root = root
      self.split = split
      self.dataset = datasets.load_dataset(
          name,  # 'name' maps to path arg in hf datasets
          split=split,
          cache_dir=self.root,  # timm doesn't expect hidden cache dir for datasets, specify a path
      )
      # leave decode for caller, plus we want easy access to original path names...
      self.dataset = self.dataset.cast_column(
          image_key, datasets.Image(decode=False)
      )
  
      self.image_key = image_key
      self.label_key = target_key
      self.remap_class = False
      if class_map:
          self.class_to_idx = load_class_map(class_map)
          self.remap_class = True
      else:
          self.class_to_idx = get_class_labels(
              self.dataset.info, self.label_key
          )
      self.split_info = self.dataset.info.splits[split]
      self.num_samples = self.split_info.num_examples
  
file_path: pytorch-image-models/timm/data/readers/reader_hfds.py
imports: import io
  import math
  from typing import Optional
  import torch
  import torch.distributed
  from PIL import Image
  from .class_map import load_class_map
  from .reader import Reader
label_desc: Use image node_id 1 to create a new ReaderHfds object from inherited base classes: Reader with example: obj = ReaderHfds(name, root, split, class_map, image_key, target_key, download)