class_docstr: This dataset class allows mini-batch formation pre-epoch, for greater speed
docstr: Args:
      image_dict: two-level dict, `super_dict[super_class_id][class_id]` gives the list of
                  image paths having the same super-label and class label
docstr_tok: ["Args",":","image_dict",":","two-level","dict",",","`","super_dict","[","super_class_id","]","[","class_id","]","`","gives","the","list","of","image","paths","having","the","same","super-label","and","class","label"]
code: def __init__(self, image_dict, opt):
      """
      Args:
          image_dict: two-level dict, `super_dict[super_class_id][class_id]` gives the list of
                      image paths having the same super-label and class label
      """
      self.image_dict = image_dict
      self.dataset_name = opt.dataset
      self.batch_size = opt.bs
      self.samples_per_class = opt.samples_per_class
      for sub in self.image_dict:
          newsub = []
          for instance in self.image_dict[sub]:
              newsub.append((sub, instance))
          self.image_dict[sub] = newsub
  
      # checks
      # provide avail_classes
      self.avail_classes = [*self.image_dict]
      # Data augmentation/processing methods.
      normalize = transforms.Normalize(
          mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
      )
      transf_list = []
  
      transf_list.extend(
          [
              transforms.RandomResizedCrop(size=224)
              if opt.arch in ["resnet50", "resnet50_mcn"]
              else transforms.RandomResizedCrop(size=227),
              transforms.RandomHorizontalFlip(0.5),
          ]
      )
      transf_list.extend([transforms.ToTensor(), normalize])
      self.transform = transforms.Compose(transf_list)
  
      self.reshuffle()
  
imports: import pickle
  import warnings
  from numpy.core.arrayprint import IntegerFormat
  import copy
  import os
  import random
  import numpy
  import pandas
  import torch
  from PIL import Image
  from torch.utils.data import Dataset
  from torchvision import transforms
label_desc: Use image node_id 1 to create a new TrainDatasetsmoothap object from inherited base classes: Dataset with example: obj = TrainDatasetsmoothap(image_dict, opt)