def _substitution_mask(sent1, sent2):
    """Binary mask identifying substituted part in two sentences.

  Example sentence and their mask:
    First sentence  = "I like the cat        's color"
                       0 0    0   1           0 0
    Second sentence = "I like the yellow dog 's color"
                       0 0    0   1      1    0 0

  Args:
    sent1: first sentence
    sent2: second sentence

  Returns:
    mask1: mask for first sentence
    mask2: mask for second sentence
  """
    mask1_start, mask2_start = [], []
    while sent1[0] == sent2[0]:
        sent1 = sent1[1:]
        sent2 = sent2[1:]
        mask1_start.append(0.)
        mask2_start.append(0.)

    mask1_end, mask2_end = [], []
    while sent1[-1] == sent2[-1]:
        if (len(sent1) == 1) or (len(sent2) == 1):
            break
        sent1 = sent1[:-1]
        sent2 = sent2[:-1]
        mask1_end = [0.] + mask1_end
        mask2_end = [0.] + mask2_end

    assert sent1 or sent2, 'Two sentences are identical.'
    return (mask1_start + [1.] * len(sent1) + mask1_end,
            mask2_start + [1.] * len(sent2) + mask2_end)