def METHOD_NAME(self, positions: torch.LongTensor) -> torch.LongTensor:
    """
    Rearange positions prior to feeding into transformer so that the existing ones,
    i.e. the first self.n_positions_init, do not change from before.
    :param LongTensor[batch,seqlen] positions:
        Positions for input IDs
    :return LongTensor[batch,seqlen] new_positions
        return positions that's shift-invariant
    """
    # max positions per sample in each batch, return batch * 1
    if self.n_positions <= self.n_positions_init:
        return positions
    pos_offset = (
        (torch.max(positions, dim=1).values - self.n_positions_init + 1)
        .unsqueeze(1)
        .clamp(min=0)
    )
    # shift the positions to the right by (max_position - self.original_n_positions).clamp_(min=0)
    # notice that remainder always return non-negative values (unlike torch.fmod), e.g. torch.remainder([-1, -2], 10) = [9, 8]
    return torch.remainder(positions - pos_offset, self.n_positions)  # type: ignore