def trailing_silence_mask(f0):
    """
    >>> f0 = torch.tensor([1.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0])
    >>> trailing_silence_mask(f0)
    tensor([False, False, False, False,  True,  True,  True])
    """
    assert f0.ndim == 1
    mask = ((f0.flip(0) != 0.0).cumsum(0) == 0).flip(0)
    return mask