def load_np_embeddings(
    *,
    urls_path, sentence_ids_path, embeddings_path):
  """Load numpy embeddings into the format expected by save_as_tsv.

  Files are read in the format used by np.save/load

  Args:
    urls_path: Path to numpy wikipedia urls file
    sentence_ids_path: Path to the sentence ids file
    embeddings_path: Path to the embeddings file

  Returns:
    Embeddings, metadata, and header for meta file
  """
  with util.log_time(f'Loading: {urls_path}'):
    with util.safe_open(urls_path, 'rb') as f:
      urls: np.ndarray = np.load(f)

  with util.log_time(f'Loading: {urls_path}'):
    with util.safe_open(sentence_ids_path, 'rb') as f:
      sentence_ids: np.ndarray = np.load(f)

  with util.log_time(f'Loading: {urls_path}'):
    with util.safe_open(embeddings_path, 'rb') as f:
      embeddings: np.ndarray = np.load(f)

  logging.info('Embedding shape: %s', embeddings.shape)

  if len({urls.shape[0], sentence_ids.shape[0], embeddings.shape[0]}) != 1:
    raise ValueError('Incompatible lengths of embedding files')

  metadata = []
  for wikipedia_url, sentence_id in zip(urls.tolist(), sentence_ids.tolist()):
    metadata.append((wikipedia_url, str(sentence_id)))

  return embeddings, metadata, 'wikipedia_url\tsentence_id'
Load numpy embeddings into the format expected by save_as_tsv.

  Files are read in the format used by np.save/load

  Args:
    urls_path: Path to numpy wikipedia urls file
    sentence_ids_path: Path to the sentence ids file
    embeddings_path: Path to the embeddings file

  Returns:
    Embeddings, metadata, and header for meta file
  
language/serene/export_embeddings.py