def _get_mcd_idx_2(divergence, examples_2, compounds_1, compounds_2,
                   get_compounds_fn, start_idx):
  """Return index of example to swap from examples_2 to examples_1."""
  for example_idx, example in _shifted_enumerate(examples_2, start_idx):
    # Compute the change in compound divergence from moving the example from
    # examples_2 to examples_1.
    compounds_example = get_compounds_fn(example)
    new_divergence = _compute_new_divergence_2(compounds_1, compounds_2,
                                               compounds_example, divergence)

    # Return the first example that we find that would increase compuond
    # divergence.
    if new_divergence > divergence:
      return example_idx, example
  return None, None
Return index of example to swap from examples_2 to examples_1.
language/compgen/nqg/tasks/mcd_utils.py