def repeat_expand_2d(content, target_len):
    """
    content : [hubert_dim(256), src_len]
    target: [hubert_dim(256), target_len]
    """
    src_len = content.shape[-1]
    target = torch.zeros([content.shape[0], target_len], dtype=torch.float).to(
        content.device
    )
    temp = torch.arange(src_len + 1) * target_len / src_len
    current_pos = 0
    for i in range(target_len):
        if i < temp[current_pos + 1]:
            target[:, i] = content[:, current_pos]
        else:
            current_pos += 1
            target[:, i] = content[:, current_pos]

    return target
content : [hubert_dim(256), src_len]
target: [hubert_dim(256), target_len]
utils/hubert.py