class_docstr: The MiniImageNet dataset.
  
  This implementation is based on the one from
  https://github.com/yaoyao-liu/mini-imagenet-tools. Differently from that,
  this class doesn't rely on a pre-generated mini imagenet folder. Instead,
  this will use the original ImageNet folder by resizing images on-the-fly.
  
  The list of included files are the ones defined in the CSVs taken from the
  aforementioned repository. Those CSVs are generated by Ravi and Larochelle.
  See the linked repository for more details.
  
  Exactly as happens with the torchvision :class:`ImageNet` class, textual
  class labels (wnids) such as "n02119789", "n02102040", etc. are mapped to
  numerical labels based on their ascending order.
  
  All the fields found in the torchvision implementation of the ImageNet
  dataset (`wnids`, `wnid_to_idx`, `classes`, `class_to_idx`) are available.
class_docstr_tok: ["The","MiniImageNet","dataset",".","This","implementation","is","based","on","the","one","from","https",":","\/\/github.com\/yaoyao-liu\/mini-imagenet-tools",".","Differently","from","that",",","this","class","does","n't","rely","on","a","pre-generated","mini","imagenet","folder",".","Instead",",","this","will","use","the","original","ImageNet","folder","by","resizing","images","on-the-fly",".","The","list","of","included","files","are","the","ones","defined","in","the","CSVs","taken","from","the","aforementioned","repository",".","Those","CSVs","are","generated","by","Ravi","and","Larochelle",".","See","the","linked","repository","for","more","details",".","Exactly","as","happens","with","the","torchvision",":","class",":","`","ImageNet","`","class",",","textual","class","labels","(","wnids",")","such","as","``","n02119789","''",",","``","n02102040","''",",","etc",".","are","mapped","to","numerical","labels","based","on","their","ascending","order",".","All","the","fields","found","in","the","torchvision","implementation","of","the","ImageNet","dataset","(","`","wnids","`",",","`","wnid_to_idx","`",",","`","classes","`",",","`","class_to_idx","`",")","are","available","."]
code: def prepare_dataset(self):
      # Read the CSV containing the file list for this split
      images: Dict[str, List[str]] = dict()
  
      csv_dir = Path(__file__).resolve().parent / "csv_files"
      if self.split == "all":
          considered_csvs = ["train.csv", "val.csv", "test.csv"]
      else:
          considered_csvs = [self.split + ".csv"]
  
      for csv_name in considered_csvs:
          csv_path = str(csv_dir / csv_name)
  
          with open(csv_path) as csvfile:
              csv_reader = csv.reader(csvfile, delimiter=",")
              next(csv_reader, None)  # Skip header
  
              for row in csv_reader:
                  if row[1] in images.keys():
                      images[row[1]].append(row[0])
                  else:
                      images[row[1]] = [row[0]]
  
      # Fill fields like wnids, wnid_to_idx, etc.
      # Those fields have the same meaning of the ones found in the
      # torchvision implementation of the ImageNet dataset. Of course some
      # work had to be done to keep this fields aligned for mini imagenet,
      # which only contains 100 classes of the original 1000.
      #
      # wnids are 'n01440764', 'n01443537', 'n01484850', etc.
      #
      # self.wnid_to_idx is a dict mapping wnids to numerical labels
      #
      # self.classes is a list mapping numerical labels (the element
      # index) to a tuple of human readable categories. For instance:
      # ('great grey owl', 'great gray owl', 'Strix nebulosa').
      #
      # self.class_to_idx is a dict mapping each string of the
      # aforementioned tuples to its numerical label. That is, it contains
      # the inverse mapping of self.classes.
      self.wnids = MINI_IMAGENET_WNIDS
      self.wnid_to_idx = MINI_IMAGENET_WNID_TO_IDX
      self.classes = MINI_IMAGENET_CLASSES
      self.class_to_idx = MINI_IMAGENET_CLASS_TO_IDX
  
      for cls in images.keys():
          cls_numerical_label = self.wnid_to_idx[cls]
          lst_files = []
          for file in glob.glob(
              str(self.imagenet_path / cls / ("*" + cls + "*"))
          ):
              lst_files.append(file)
  
          lst_index = [
              int(i[i.rfind("_") + 1 : i.rfind(".")]) for i in lst_files
          ]
          index_sorted = sorted(
              range(len(lst_index)), key=lst_index.__getitem__
          )
  
          index_selected = [
              int(i[i.index(".") - 4 : i.index(".")])
              for i in images[cls]
          ]
          selected_images = np.array(index_sorted)[
              np.array(index_selected) - 1
          ]
          for i in np.arange(len(selected_images)):
              self.image_paths.append(lst_files[selected_images[i]])
              self.targets.append(cls_numerical_label)
  
file_path: avalanche/avalanche/benchmarks/datasets/mini_imagenet/mini_imagenet.py
imports: import csv
  import glob
  from pathlib import Path
  from typing import Union, List, Tuple, Dict
  from torchvision.datasets.folder import default_loader
  from typing_extensions import Literal
  import PIL
  import numpy
  from PIL import Image
  from torch.utils.data.dataset import Dataset
  from torchvision.transforms import Resize
  from avalanche.benchmarks.datasets.mini_imagenet.mini_imagenet_data import MINI_IMAGENET_WNIDS, MINI_IMAGENET_WNID_TO_IDX, MINI_IMAGENET_CLASSES, MINI_IMAGENET_CLASS_TO_IDX
label_desc: Use image node_id 3 for calling the MiniImageNetDataset obj's underlying member method code with example usage: obj.prepare_dataset() without return types