def process_data(
    raw_samples: List[Dict[str, Any]],
    relation_vocab: Dict[str, int],
    spacy_model: Any,
    tokenizer: Any,
) -> Tuple[List[Dict[str, Any]], Dict[str, int]]:
  """Process Tacred split and updates relation vocabulary with new relations."""

  skipped = 0
  processed_samples = []
  for sample in tqdm.tqdm(raw_samples):
    processed_sample, relation_vocab = process_sample(
        sample=sample,
        relation_vocab=relation_vocab,
        spacy_model=spacy_model,
        tokenizer=tokenizer,
    )
    if processed_sample is not None:
      processed_samples.append(processed_sample)
    else:
      skipped += 1

  logging.info('Skipped %s samples', skipped)

  return processed_samples, relation_vocab
Process Tacred split and updates relation vocabulary with new relations.
language/mentionmemory/data/prepare_tacred.py