def METHOD_NAME(x: torch.Tensor, dim: int, duration: int):
    assert not x.requires_grad
    assert dim < 0
    dots = (slice(None),) * (x.dim() + dim)
    left = dots + (slice(None, duration),)
    right = dots + (slice(duration, None),)
    return idct(x[right], dim)[left].add_(x[left])