docs: def prepare_metadata(devkit_archive, test_groundtruth_path):
      """Extract dataset metadata required for HDF5 file setup.
  
      Parameters
      ----------
      devkit_archive : str or file-like object
          The filename or file-handle for the gzipped TAR archive
          containing the ILSVRC2010 development kit.
      test_groundtruth_path : str or file-like object
          The filename or file-handle for the text file containing
          the ILSVRC2010 test set ground truth.
  
      Returns
      -------
      n_train : int
          The number of examples in the training set.
      valid_groundtruth : ndarray, 1-dimensional
          An ndarray containing the validation set groundtruth in terms of
          0-based class indices.
      test_groundtruth : ndarray, 1-dimensional
          An ndarray containing the test groundtruth in terms of 0-based
          class indices.
      wnid_map : dict
          A dictionary that maps WordNet IDs to 0-based class indices.
  
      """
      # Read what's necessary from the development kit.
      synsets, cost_matrix, raw_valid_groundtruth = read_devkit(devkit_archive)
  
      # Mapping to take WordNet IDs to our internal 0-999 encoding.
      wnid_map = dict(zip((s.decode('utf8') for s in synsets['WNID']),
                          xrange(1000)))
  
      # Map the 'ILSVRC2010 ID' to our zero-based ID.
      ilsvrc_id_to_zero_based = dict(zip(synsets['ILSVRC2010_ID'],
                                     xrange(len(synsets))))
  
      # Map the validation set groundtruth to 0-999 labels.
      valid_groundtruth = [ilsvrc_id_to_zero_based[id_]
                           for id_ in raw_valid_groundtruth]
  
      # Raw test data groundtruth, ILSVRC2010 IDs.
      raw_test_groundtruth = numpy.loadtxt(test_groundtruth_path,
                                           dtype=numpy.int16)
  
      # Map the test set groundtruth to 0-999 labels.
      test_groundtruth = [ilsvrc_id_to_zero_based[id_]
                          for id_ in raw_test_groundtruth]
  
      # Ascertain the number of filenames to prepare appropriate sized
      # arrays.
      n_train = int(synsets['num_train_images'].sum())
      log.info('Training set: {} images'.format(n_train))
      log.info('Validation set: {} images'.format(len(valid_groundtruth)))
      log.info('Test set: {} images'.format(len(test_groundtruth)))
      n_total = n_train + len(valid_groundtruth) + len(test_groundtruth)
      log.info('Total (train/valid/test): {} images'.format(n_total))
      return n_train, valid_groundtruth, test_groundtruth, wnid_map