code: def image_per_label(
      images, label_indices, label_names, max_size=2000
  ):
      groups = defaultdict(list)
      for i, label_idx in enumerate(label_indices):
          label = (
              label_names[label_idx].lower().strip().replace(" ", "_")
          )
          groups[label].append(images[i])
  
      # as a pretty arbitrary heuristic, let's try taking the min variance
      # image for each person
      singe_images = {}
      for label, images in sorted(groups.items()):
          singe_images[label] = min(
              images, key=lambda image: image.std()
          )
          if max_size and len(singe_images) >= max_size:
              break
      return singe_images
  
imports: from os import mkdir
  from os.path import exists, join
  from collections import defaultdict
  import pylab
  from sklearn.datasets import fetch_lfw_people
  from sklearn.impute import IterativeImputer
  import numpy
  from fancyimpute import SimpleFill, IterativeSVD, SoftImpute, BiScaler, KNN
  from fancyimpute.common import masked_mae, masked_mse
label_desc: Use image node_id 4 for calling a global function with example usage: image_per_label(images, label_indices, label_names, max_size) and returns: singe_images