Note that I get this error in Python 3.8.6 and pytorch 1.6.0 on a Mac OS. I tried debugging this problem further. You can reproduce the error by running the following standalone code. It seems like the error is related to numpy to tensor conversion. Towards the end of the below code, I describe an approach to get rid of this error by defining numpy arrays differently. So, it seems like the contiguous or discontiguous nature of arrays is inherited from numpy.
Also, how do I properly render the code below? Some parts are rendered, while some other appear as text.
import torch
import numpy as np


class ModelTest(torch.nn.Module):
    def __init__(self, N_y, N_x, d):
        super(ModelTest, self).__init__()
        tran = np.random.randn(d, 1, N_y, N_x, 2).astype(
            np.double, order='C')
        self.transform = torch.tensor(
            tran, dtype=torch.double, requires_grad=False)

    def forward(self, x):
        x = torch.fft(x, signal_ndim=2)
        y_real = x[:, :, :, :, 0]*self.transform[:, :, :, :, 0] - \
            x[:, :, :, :, 1]*self.transform[:, :, :, :, 1]
        y_imag = x[:, :, :, :, 0]*self.transform[:, :, :, :, 1] + \
            x[:, :, :, :, 1]*self.transform[:, :, :, :, 0]
        x = torch.stack((y_real, y_imag), dim=-1)
        x = torch.ifft(x, signal_ndim=2)
        x = x[:, :, :, :, 0]*x[:, :, :, :, 0]+x[:, :, :, :, 1]*x[:, :, :, :, 1]
        return x


class ModelTestOpt(torch.nn.Module):
    def __init__(self, init, N_y, N_x, d):
        super(ModelTestOpt, self).__init__()
        self.model = ModelTest(N_y, N_x, d)
        self.rec = torch.nn.Parameter(torch.tensor(
            init, dtype=torch.double, requires_grad=True))

    def forward(self):
        return self.model(self.rec)


class Sim_Algo:
    def __init__(self, N_y, N_x, d):
        self.model = ModelTest(N_y, N_x, d)

    def run(self, data):
        data = torch.tensor(data, dtype=torch.double, requires_grad=False)
        new_shape = (-1, data.size(-4), data.size(-3),
                     data.size(-2), data.size(-1))
        data = torch.reshape(data, new_shape)
        return self.model(data)


class Iter_Algo:
    def __init__(self, init, N_y, N_x, d):
        init = init.reshape(
            (-1, init.shape[-4], init.shape[-3], init.shape[-2], init.shape[-1]))
        self.model = ModelTestOpt(init, N_y, N_x, d)
        self.loss_fn = torch.nn.MSELoss(reduce=True, reduction='mean')
        self.optimizer = torch.optim.LBFGS(self.model.parameters(), lr=1, max_iter=20, max_eval=None,
                                           tolerance_grad=1e-07, tolerance_change=1e-09, history_size=10, line_search_fn='strong_wolfe')

    def run(self, data):
        data = torch.tensor(data, dtype=torch.double, requires_grad=False)

        def closure():
            if torch.is_grad_enabled():
                self.optimizer.zero_grad()
            data_pred = self.model()
            loss = self.loss_fn(data_pred, data)
            if loss.requires_grad:
                loss.backward()
            return loss

        loss = self.loss_fn(self.model(), data).detach().numpy()
        print('Init loss: ', loss)
        self.optimizer.step(closure)

        loss = self.loss_fn(
            self.model(), data).detach().numpy()
        print('Final loss: ', loss)

        rec = self.model.rec.detach().numpy()
        return rec, loss


N_y, N_x = 72, 96
d = 3

init = np.random.randn(1, N_y, N_x, 2).astype(dtype=np.double, order='C')
transform = np.random.randn(d, N_y, N_x, 2).astype(dtype=np.double, order='C')

simtor = Sim_Algo(N_y, N_x, d)
data = simtor.run(init)

# Comment next three lines to prevent error
init = np.random.randn(1, N_y, N_x)+1j*np.random.randn(1, N_y, N_x)
init = np.stack((np.real(init), np.imag(init)),
                axis=0).astype(dtype=np.double, order='C')
init = np.moveaxis(init, 0, -1)
# Uncomment below line to prevent error
#init = np.random.randn(1, N_y, N_x, 2).astype(dtype=np.double, order='C')
solver = Iter_Algo(init, N_y, N_x, d)
solver.run(data)