def generate_realm_examples(featurizer, retriever, model_timestamp):
  """Generates examples for REALM pre-training.

  Args:
    featurizer: instance of featurization.Featurizer
    retriever: instance of retrieval.Retriever
    model_timestamp (int): integer tracking the time when model was saved.

  Yields:
    query: a Query object.
    docs: a list of Documents. These are the candidates retrieved for the query.
    example: a TF Example holding the featurized representation of the query
      and the docs.
  """
  query_cand_pairs = generate_queries_and_candidates(featurizer, retriever)
  for i, (query, cands) in enumerate(query_cand_pairs):
    ex = featurizer.query_and_docs_to_tf_example(query, cands, model_timestamp)
    yield query, cands, ex

    if i % 100 == 0:
      logging.info('Example generation stats @ %d: %s', i, str(STATS))
Generates examples for REALM pre-training.

  Args:
    featurizer: instance of featurization.Featurizer
    retriever: instance of retrieval.Retriever
    model_timestamp (int): integer tracking the time when model was saved.

  Yields:
    query: a Query object.
    docs: a list of Documents. These are the candidates retrieved for the query.
    example: a TF Example holding the featurized representation of the query
      and the docs.
  
language/realm/example_generator.py