I have solved the problem.
I used grad_output.contiguous() before max_pooling.backward(grad_output, ctx.argmax, grad_input) in py file, and it worked.
    @staticmethod
    def backward(ctx, grad_output):
        # grad_output is not contiguous here. But I do not know why.
        grad_output = grad_output.contiguous()
        grad_input = torch.zeros(ctx.n_features, ctx.n_channels, device=grad_output.device, dtype=grad_output.dtype)
        max_pooling.backward(grad_output, ctx.argmax, grad_input)
        return grad_input

Thanks again.