The new error doesn’t seem to be an equivalent error, since the forward pass is failing due to an expected shape mismatch in the Encoder.
Change:
nn.Linear(2*16*c_hid, latent_dim)

to
nn.Linear(41216, latent_dim)

and the model works for me:
num_input_channels, width, height = 182, 218, 182        
example_input_array = torch.zeros(10, num_input_channels, width, height)
model = Autoencoder(base_channel_size=32, latent_dim=64, num_input_channels=182) 

output = model(example_input_array)
output.mean().backward()

so that I cannot reproduce the initially reported shape mismatch in the backward pass.
I don’t know why your initial Lightning model didn’t report the shape mismatch in the forward pass.