docstr: Different from mnistNShot, the
  :param root:
  :param batchsz: task num
  :param n_way:
  :param k_shot:
  :param k_query:
  :param imgsz:
docstr_tok: ["Different","from","mnistNShot",",","the",":","param","root",":",":","param","batchsz",":","task","num",":","param","n_way",":",":","param","k_shot",":",":","param","k_query",":",":","param","imgsz",":"]
code: def __init__(
      self, root, batchsz, n_way, k_shot, k_query, imgsz, device=None
  ):
      """
      Different from mnistNShot, the
      :param root:
      :param batchsz: task num
      :param n_way:
      :param k_shot:
      :param k_query:
      :param imgsz:
      """
  
      self.resize = imgsz
      self.device = device
      if not os.path.isfile(os.path.join(root, "omniglot.npy")):
          # if root/data.npy does not exist, just download it
          self.x = Omniglot(
              root,
              download=True,
              transform=transforms.Compose(
                  [
                      lambda x: Image.open(x).convert("L"),
                      lambda x: x.resize((imgsz, imgsz)),
                      lambda x: np.reshape(x, (imgsz, imgsz, 1)),
                      lambda x: np.transpose(x, [2, 0, 1]),
                      lambda x: x / 255.0,
                  ]
              ),
          )
  
          temp = (
              {}
          )  # {label:img1, img2..., 20 imgs, label2: img1, img2,... in total, 1623 label}
          for img, label in self.x:
              if label in temp.keys():
                  temp[label].append(img)
              else:
                  temp[label] = [img]
  
          self.x = []
          for (
              label,
              imgs,
          ) in (
              temp.items()
          ):  # labels info deserted , each label contains 20imgs
              self.x.append(np.array(imgs))
  
          # as different class may have different number of imgs
          self.x = np.array(self.x).astype(
              np.float64
          )  # [[20 imgs],..., 1623 classes in total]
          # each character contains 20 imgs
          print("data shape:", self.x.shape)  # [1623, 20, 84, 84, 1]
          temp = []  # Free memory
          # save all dataset into npy file.
          np.save(os.path.join(root, "omniglot.npy"), self.x)
          print("write into omniglot.npy.")
      else:
          # if data.npy exists, just load it.
          self.x = np.load(os.path.join(root, "omniglot.npy"))
          print("load from omniglot.npy.")
  
      # [1623, 20, 84, 84, 1]
      # TODO: can not shuffle here, we must keep training and test set distinct!
      self.x_train, self.x_test = self.x[:1200], self.x[1200:]
  
      # self.normalization()
  
      self.batchsz = batchsz
      self.n_cls = self.x.shape[0]  # 1623
      self.n_way = n_way  # n way
      self.k_shot = k_shot  # k shot
      self.k_query = k_query  # k query
      assert (k_shot + k_query) <= 20
  
      # save pointer of current read batch in total cache
      self.indexes = {"train": 0, "test": 0}
      self.datasets = {
          "train": self.x_train,
          "test": self.x_test,
      }  # original data cached
      print("DB: train", self.x_train.shape, "test", self.x_test.shape)
  
      self.datasets_cache = {
          "train": self.load_data_cache(
              self.datasets["train"]
          ),  # current epoch data cached
          "test": self.load_data_cache(self.datasets["test"]),
      }
  
imports: import errno
  import os
  import os.path
  import numpy
  import torch
  import torch.utils.data
  import torchvision.transforms
  from PIL import Image
label_desc: Use image node_id 1 to create a new OmniglotNShot object  with example: obj = OmniglotNShot(root, batchsz, n_way, k_shot, k_query, imgsz, device)