code: def _extract_mnist_labels(filename, num_labels):
    
    with gzip.open(filename) as bytestream:
      bytestream.read(8)
      buf = bytestream.read(num_labels)
      labels = np.frombuffer(buf, dtype=np.uint8).astype(np.int64)
    return labels
docs: Extract labels from an MNIST file into integers.
  
    Args:
      filename: The path to an MNIST labels file.
      num_labels: The number of labels in the file.
  
    Returns:
      A int64 numpy array of shape [num_labels]