code: def dense_to_one_hot(labels_dense, num_classes):
      """Convert class labels from scalars to one-hot vectors."""
      num_labels = labels_dense.shape[0]
      index_offset = np.arange(num_labels) * num_classes
      labels_one_hot = np.zeros((num_labels, num_classes))
      labels_one_hot.flat[
          index_offset + labels_dense.ravel()
      ] = 1  # pylint:disable=unsupported-assignment-operation
      return labels_one_hot
  
file_path: magenta/magenta/models/latent_transfer/local_mnist.py
imports: import gzip
  import os
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: dense_to_one_hot(labels_dense, num_classes) and returns: labels_one_hot