text: import torch
  import os.path as osp
  from PIL import Image
  
  from torch.utils.data import Dataset
  from torchvision import transforms
  from tqdm import tqdm
  import numpy as np
  
  THIS_PATH = osp.dirname(__file__)
  ROOT_PATH = osp.abspath(osp.join(THIS_PATH, '..', '..'))
  ROOT_PATH2 = osp.abspath(osp.join(THIS_PATH, '..', '..', '..'))
  #IMAGE_PATH1 = osp.join(ROOT_PATH, 'data/miniimagenet/images')
  #SPLIT_PATH = osp.join(ROOT_PATH, 'data/miniimagenet/split')
  #CACHE_PATH = osp.join(ROOT_PATH, 'cache/')
  
  def identity(x):
      return x
      
  
  class MiniImageNet(Dataset):
      """ Usage:
      """
      def __init__(self, setname, args, augment=False):
          
          
          self.IMAGE_PATH1 = osp.join(args.data_path, 'images')
          self.SPLIT_PATH = osp.join(args.data_path, 'split')
          
          csv_path = osp.join(self.SPLIT_PATH, setname + '.csv')
          
          self.data, self.label = self.parse_csv(csv_path, setname)
  
          self.num_class = len(set(self.label))
  
          image_size = 84
          if augment and setname == 'train':
              transforms_list = [
                    transforms.RandomResizedCrop(image_size),
                    transforms.ColorJitter(brightness=0.4, contrast=0.4, saturation=0.4),
                    transforms.RandomHorizontalFlip(),
                    transforms.ToTensor(),
                  ]
          else:
              transforms_list = [
                    transforms.Resize(92),
                    transforms.CenterCrop(image_size),
                    transforms.ToTensor(),
                  ]
  
          # Transformation
          if args.backbone_class == 'ConvNet':
              self.transform = transforms.Compose(
                  transforms_list + [
                  transforms.Normalize(np.array([0.485, 0.456, 0.406]),
                                       np.array([0.229, 0.224, 0.225]))
              ])
          elif args.backbone_class == 'Res12':
              self.transform = transforms.Compose(
                  transforms_list + [
                  transforms.Normalize(np.array([x / 255.0 for x in [120.39586422,  115.59361427, 104.54012653]]),
                                       np.array([x / 255.0 for x in [70.68188272,   68.27635443,  72.54505529]]))
              ])
          elif args.backbone_class == 'Res18':
              self.transform = transforms.Compose(
                  transforms_list + [
                  transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                       std=[0.229, 0.224, 0.225])
              ])            
          elif args.backbone_class == 'WRN':
              self.transform = transforms.Compose(
                  transforms_list + [
                  transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                       std=[0.229, 0.224, 0.225])
              ])         
          else:
              raise ValueError('Non-supported Network Types. Please Revise Data Pre-Processing Scripts.')
      
  
      def parse_csv(self, csv_path, setname):
          lines = [x.strip() for x in open(csv_path, 'r').readlines()][1:]
  
          data = []
          label = []
          lb = -1
  
          self.wnids = []
  
          for l in tqdm(lines, ncols=64):
              name, wnid = l.split(',')
              path = osp.join(self.IMAGE_PATH1, name)
              if wnid not in self.wnids:
                  self.wnids.append(wnid)
                  lb += 1
              data.append( path )
              label.append(lb)
  
          return data, label
  
      def __len__(self):
          return len(self.data)
  
      def __getitem__(self, i):
          data, label = self.data[i], self.label[i]
          image = self.transform(Image.open(data).convert('RGB'))
          
          return image, label
  
  