class_docstr: Dataset class to provide (augmented) correctly prepared training samples corresponding to standard DML literature.
  This includes normalizing to ImageNet-standards, and Random & Resized cropping of shapes 224 for ResNet50 and 227 for
  GoogLeNet during Training. During validation, only resizing to 256 or center cropping to 224/227 is performed.
docstr: Args:
      idx: Sample idx for training sample
  Returns:
      tuple of form (sample_class, torch.Tensor() of input image)
docstr_tok: ["Args",":","idx",":","Sample","idx","for","training","sample","Returns",":","tuple","of","form","(","sample_class",",","torch.Tensor","(",")","of","input","image",")"]
code: def __getitem__(self, idx):
      """
      Args:
          idx: Sample idx for training sample
      Returns:
          tuple of form (sample_class, torch.Tensor() of input image)
      """
      if (
          self.pars.loss == "smoothap"
          or self.pars.loss == "smoothap_element"
      ):
          if self.is_init:
              # self.current_class = self.avail_classes[idx%len(self.avail_classes)]
              self.is_init = False
  
          if not self.is_validation:
              if self.samples_per_class == 1:
                  return self.image_list[idx][-1], self.transform(
                      self.ensure_3dim(
                          Image.open(self.image_list[idx][0])
                      )
                  )
  
              if self.n_samples_drawn == self.samples_per_class:
                  # Once enough samples per class have been drawn, we choose another class to draw samples from.
                  # Note that we ensure with self.classes_visited that no class is chosen if it had been chosen
                  # previously or one before that.
                  counter = copy.deepcopy(self.avail_classes)
                  for prev_class in self.classes_visited:
                      if prev_class in counter:
                          counter.remove(prev_class)
  
                  self.current_class = counter[idx % len(counter)]
                  # self.classes_visited = self.classes_visited[1:]+[self.current_class]
                  # EDIT -> there can be no class repeats
                  self.classes_visited = self.classes_visited + [
                      self.current_class
                  ]
                  self.n_samples_drawn = 0
  
              class_sample_idx = idx % len(
                  self.image_dict[self.current_class]
              )
              self.n_samples_drawn += 1
  
              out_img = self.transform(
                  self.ensure_3dim(
                      Image.open(
                          self.image_dict[self.current_class][
                              class_sample_idx
                          ]
                      )
                  )
              )
              return self.current_class, out_img
          else:
              return self.image_list[idx][-1], self.transform(
                  self.ensure_3dim(Image.open(self.image_list[idx][0]))
              )
      else:
          if self.is_init:
              self.current_class = self.avail_classes[
                  idx % len(self.avail_classes)
              ]
              self.is_init = False
          if not self.is_validation:
              if self.samples_per_class == 1:
                  return self.image_list[idx][-1], self.transform(
                      self.ensure_3dim(
                          Image.open(self.image_list[idx][0])
                      )
                  )
  
              if self.n_samples_drawn == self.samples_per_class:
                  # Once enough samples per class have been drawn, we choose another class to draw samples from.
                  # Note that we ensure with self.classes_visited that no class is chosen if it had been chosen
                  # previously or one before that.
                  counter = copy.deepcopy(self.avail_classes)
                  for prev_class in self.classes_visited:
                      if prev_class in counter:
                          counter.remove(prev_class)
  
                  self.current_class = counter[idx % len(counter)]
                  self.classes_visited = self.classes_visited[1:] + [
                      self.current_class
                  ]
                  self.n_samples_drawn = 0
  
              class_sample_idx = idx % len(
                  self.image_dict[self.current_class]
              )
              self.n_samples_drawn += 1
  
              out_img = self.transform(
                  self.ensure_3dim(
                      Image.open(
                          self.image_dict[self.current_class][
                              class_sample_idx
                          ]
                      )
                  )
              )
              return self.current_class, out_img
          else:
              return self.image_list[idx][-1], self.transform(
                  self.ensure_3dim(Image.open(self.image_list[idx][0]))
              )
  
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 3 for calling the BaseTripletDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: self,  out_img, self,  self, self,  out_img, self,  self, self,  self, self,  self