class_docstr: INATURALIST Pytorch Dataset
  
  For default selection of 10 supercategories:
  
  - Training Images in total: 428,830
  - Validation Images in total:  23,229
  - Shape of images: torch.Size([1, 3, 600, 800])
  - Class counts per supercategory (both train/val):
  
      - 'Amphibia': 144,
      - 'Animalia': 178,
      - 'Arachnida': 114,
      - 'Aves': 1258,
      - 'Fungi': 321,
      - 'Insecta': 2031,
      - 'Mammalia': 234,
      - 'Mollusca': 262,
      - 'Plantae': 2917,
      - 'Reptilia': 284}
class_docstr_tok: ["INATURALIST","Pytorch","Dataset","For","default","selection","of","10","supercategories",":","-","Training","Images","in","total",":","428,830","-","Validation","Images","in","total",":","23,229","-","Shape","of","images",":","torch.Size","(","[","1",",","3",",","600",",","800","]",")","-","Class","counts","per","supercategory","(","both","train\/val",")",":","-","'Amphibia","'",":","144",",","-","'Animalia","'",":","178",",","-","'Arachnida","'",":","114",",","-","'Aves","'",":","1258",",","-","'Fungi","'",":","321",",","-","'Insecta","'",":","2031",",","-","'Mammalia","'",":","234",",","-","'Mollusca","'",":","262",",","-","'Plantae","'",":","2917",",","-","'Reptilia","'",":","284","}"]
code: def __init__(
      self,
      root=expanduser("~") + "/.avalanche/data/inaturalist2018/",
      split="train",
      transform=ToTensor(),
      target_transform=None,
      loader=pil_loader,
      download=True,
      supcats=None,
  ):
      super().__init__()
      # conda install -c conda-forge pycocotools
      from pycocotools.coco import COCO as jsonparser
  
      assert split in self.splits
      self.split = split  # training set or test set
      self.transform = transform
      self.target_transform = target_transform
      self.root = root
      self.loader = loader
      self.log = logging.getLogger("avalanche")
  
      # Supercategories to include (None = all)
      self.supcats = (
          supcats if supcats is not None else self.def_supcats
      )
  
      if download:
          download_trainval = self.split in ["train", "val"]
          self.inat_data = INATURALIST_DATA(
              data_folder=root, trainval=download_trainval
          )
  
      # load annotations
      ann_file = f"{split}2018.json"
      self.log.info(f"Loading annotations from: {ann_file}")
      self.ds = jsonparser(annotation_file=os.path.join(root, ann_file))
  
      self.img_ids, self.targets = [], []  # targets field is required!
      self.cats_per_supcat: Dict[str, Set[int]] = {}
  
      # Filter full dataset parsed
      for ann in self.ds.anns.values():
          img_id = ann["image_id"]
          cat_id = ann["category_id"]
  
          # img = self.ds.loadImgs(img_id)[0]["file_name"]  # Img Path
          cat = self.ds.loadCats(cat_id)[0]  # Get category
          target = cat["name"]  # Is subdirectory
          supcat = cat["supercategory"]  # Is parent directory
  
          if (
              self.supcats is None or supcat in self.supcats
          ):  # Made selection
              # Add category to supercategory
              if supcat not in self.cats_per_supcat:
                  self.cats_per_supcat[supcat] = set()
              self.cats_per_supcat[supcat].add(int(target))  # Need int
  
              # Add to list
              self.img_ids.append(img_id)
              self.targets.append(target)
              # self.suptargets.append(supcat)
  
      cnt_per_supcat = {
          k: len(v) for k, v in self.cats_per_supcat.items()
      }
      self.log.info("Classes per supercategories:")
      self.log.info(pprint.pformat(cnt_per_supcat, indent=2))
      self.log.info(f"Images in total: {self.__len__()}")
  
file_path: avalanche/avalanche/benchmarks/datasets/inaturalist/inaturalist.py
imports: from typing import Any, Dict, List, Set
  import os
  import logging
  from torch.utils.data.dataset import Dataset
  from torchvision.transforms import ToTensor
  from PIL import Image
  from os.path import expanduser
  import pprint
  from .inaturalist_data import INATURALIST_DATA
label_desc: Use image node_id 1 to create a new INATURALIST2018 object from inherited base classes: Dataset with example: obj = INATURALIST2018(root, split, transform, target_transform, loader, download, supcats)