code: def get_index_grouped_by_label(labels):
      """Get (an array of) index grouped by label.
  
      This array is used for label-level sampling.
      It aims at MNIST and CelebA (in Jesse et al. 2018) with 10 labels.
  
      Args:
        labels: a list of labels in integer.
  
      Returns:
        A (# label - sized) list of lists contatining indices of that label.
      """
      index_grouped_by_label = [[] for _ in range(10)]
      for i, label in enumerate(labels):
          index_grouped_by_label[label].append(i)
      return index_grouped_by_label
  
imports: import functools
  import importlib
  import os
  from magenta.models.latent_transfer import local_mnist
  import numpy
  from PIL import Image
  import tensorflow.compat.v1
label_desc: Use image node_id 7 for calling a global function with example usage: get_index_grouped_by_label(labels) and returns: index_grouped_by_label