code: def extract_labels(self, f, one_hot=False, num_classes=10):
          
          print('Extracting', f.name)
          with gzip.GzipFile(fileobj=f) as bytestream:
              magic = self._read32(bytestream)
              if magic != 2049:
                  raise ValueError('Invalid magic number %d in MNIST label file: %s' %
                                   (magic, f.name))
              num_items = self._read32(bytestream)
              buf = bytestream.read(num_items)
              labels = np.frombuffer(buf, dtype=np.uint8)
              if one_hot:
                  return self.dense_to_one_hot(labels, num_classes)
              return labels
docs: Extract the labels into a 1D uint8 numpy array [index].
          Args:
            f: A file object that can be passed into a gzip reader.
            one_hot: Does one hot encoding for the result.
            num_classes: Number of classes for the one hot encoding.
          Returns:
            labels: a 1D unit8 numpy array.
          Raises:
            ValueError: If the bystream doesn't start with 2049.