import torch


def fill_tail_dims(
    y: torch.Tensor,
    y_like: torch.Tensor,
):
    """Fill in missing trailing dimensions for y according to y_like."""
    return y[(...,) + (None,) * (y_like.dim() - y.dim())]