code: def extract_mnist_labels(filename, num_images):
      """
      Extract the labels into a vector of int64 label IDs.
      """
      if not tf.gfile.Exists(filename + ".npy"):
          with gzip.open(filename) as bytestream:
              bytestream.read(8)
              buf = bytestream.read(1 * num_images)
              labels = np.frombuffer(buf, dtype=np.uint8).astype(
                  np.int32
              )
              np.save(filename, labels)
          return labels
      else:
          with tf.gfile.Open(filename + ".npy", mode="rb") as file_obj:
              return np.load(file_obj)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gzip
  import math
  import os
  import sys
  import tarfile
  import numpy
  from scipy.io import loadmat
  from six.moves import cPickle
  from six.moves import urllib
  from six.moves import xrange
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling a global function with example usage: extract_mnist_labels(filename, num_images) and returns: labels, np