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","."]
docstr: Creates an instance of the Mini ImageNet dataset.
  
  This dataset allows to obtain the whole dataset or even only specific
  splits. Beware that, when using a split different that "all", the
  returned dataset will contain patterns of a subset of the 100 classes.
  This happens because MiniImagenet was created with the idea of training,
  validating and testing on a disjoint set of classes.
  
  This implementation uses the filelists provided by
  https://github.com/yaoyao-liu/mini-imagenet-tools, which are the ones
  generated by Ravi and Larochelle (see the linked repo for more details).
  
  :param imagenet_path: The path to the imagenet folder. This has to be
      the path to the full imagenet 2012 folder (plain, not resized).
      Only the "train" folder will be used. Because of this, passing the
      path to the imagenet 2012 "train" folder is also allowed.
  :param split: The split to obtain. Defaults to "all". Valid values are
      "all", "train", "val" and "test".
  :param resize_to: The size of the output images. Can be an `int` value
      or a tuple of two ints. When passing a single `int` value, images
      will be resized by forcing as 1:1 aspect ratio. Defaults to 84,
      which means that images will have size 84x84.
docstr_tok: ["Creates","an","instance","of","the","Mini","ImageNet","dataset",".","This","dataset","allows","to","obtain","the","whole","dataset","or","even","only","specific","splits",".","Beware","that",",","when","using","a","split","different","that","``","all","''",",","the","returned","dataset","will","contain","patterns","of","a","subset","of","the","100","classes",".","This","happens","because","MiniImagenet","was","created","with","the","idea","of","training",",","validating","and","testing","on","a","disjoint","set","of","classes",".","This","implementation","uses","the","filelists","provided","by","https",":","\/\/github.com\/yaoyao-liu\/mini-imagenet-tools",",","which","are","the","ones","generated","by","Ravi","and","Larochelle","(","see","the","linked","repo","for","more","details",")",".",":","param","imagenet_path",":","The","path","to","the","imagenet","folder",".","This","has","to","be","the","path","to","the","full","imagenet","2012","folder","(","plain",",","not","resized",")",".","Only","the","``","train","''","folder","will","be","used",".","Because","of","this",",","passing","the","path","to","the","imagenet","2012","``","train","''","folder","is","also","allowed",".",":","param","split",":","The","split","to","obtain",".","Defaults","to","``","all","''",".","Valid","values","are","``","all","''",",","``","train","''",",","``","val","''","and","``","test","''",".",":","param","resize_to",":","The","size","of","the","output","images",".","Can","be","an","`","int","`","value","or","a","tuple","of","two","ints",".","When","passing","a","single","`","int","`","value",",","images","will","be","resized","by","forcing","as","1:1","aspect","ratio",".","Defaults","to","84",",","which","means","that","images","will","have","size","84x84","."]
code: def __init__(
      self,
      imagenet_path: Union[str, Path],
      split: Literal["all", "train", "val", "test"] = "all",
      resize_to: Union[int, Tuple[int, int]] = 84,
      loader=default_loader,
  ):
      """
      Creates an instance of the Mini ImageNet dataset.
  
      This dataset allows to obtain the whole dataset or even only specific
      splits. Beware that, when using a split different that "all", the
      returned dataset will contain patterns of a subset of the 100 classes.
      This happens because MiniImagenet was created with the idea of training,
      validating and testing on a disjoint set of classes.
  
      This implementation uses the filelists provided by
      https://github.com/yaoyao-liu/mini-imagenet-tools, which are the ones
      generated by Ravi and Larochelle (see the linked repo for more details).
  
      :param imagenet_path: The path to the imagenet folder. This has to be
          the path to the full imagenet 2012 folder (plain, not resized).
          Only the "train" folder will be used. Because of this, passing the
          path to the imagenet 2012 "train" folder is also allowed.
      :param split: The split to obtain. Defaults to "all". Valid values are
          "all", "train", "val" and "test".
      :param resize_to: The size of the output images. Can be an `int` value
          or a tuple of two ints. When passing a single `int` value, images
          will be resized by forcing as 1:1 aspect ratio. Defaults to 84,
          which means that images will have size 84x84.
      """
      self.imagenet_path = MiniImageNetDataset.get_train_path(
          imagenet_path
      )
      """
          The path to the "train" folder of full imagenet 2012 directory.
          """
  
      self.split: Literal["all", "train", "val", "test"] = split
      """
          The required split.
          """
  
      if isinstance(resize_to, int):
          resize_to = (resize_to, resize_to)
  
      self.resize_to: Tuple[int, int] = resize_to
      """
          The size of the output images, as a two ints tuple.
          """
  
      # NOTE: the original loader from yaoyao-liu uses cv2.INTER_AREA
      self._transform = Resize(
          self.resize_to, interpolation=PIL.Image.BILINEAR
      )
  
      # The following fields are filled by self.prepare_dataset()
      self.image_paths: List[str] = []
      """
          The paths to images.
          """
  
      self.targets: List[int] = []
      """
          The class labels for the patterns. Aligned with the image_paths field.
          """
  
      self.wnids: List[str] = []
      """
          The list of wnids (the textual class labels, such as "n02119789").
          """
  
      self.wnid_to_idx: Dict[str, int] = dict()
      """
          A dictionary mapping wnids to numerical labels in range [0, 100).
          """
  
      self.classes: List[Tuple[str, ...]] = []
      """
          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: Dict[str, int] = dict()
      """
          A dictionary mapping each string of the tuples found in the classes 
          field to their numerical label. That is, this dictionary contains the 
          inverse mapping of classes field.
          """
  
      self.loader = loader
  
      if not self.imagenet_path.exists():
          raise ValueError("The provided directory does not exist.")
  
      if self.split not in ["all", "train", "val", "test"]:
          raise ValueError(
              'Invalid split. Valid values are: "train", "val", '
              '"test"'
          )
  
      self.prepare_dataset()
  
      super().__init__()
  
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 1 to create a new MiniImageNetDataset object from inherited base classes: Dataset with example: obj = MiniImageNetDataset(imagenet_path, split, resize_to, loader)