My model:

class Net(nn.Module):
    def __init__(self, batch_size):
        super(Net, self).__init__()
        self.batch_size = batch_size
        self.conv1 = nn.Conv2d(1, 2, 3)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(2, 1, 3)
        self.fc1 = nn.Linear(self.batch_size * 2 * 14, 2048)
        self.fc2 = nn.Linear(2048, self.batch_size)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(self.batch_size * 2 * 14)
        x = F.relu(self.fc1(x))
        x = self.fc2(x)
        return x

and this is how i am calling it:
y_pred = model(x)
The shape of the x is (batch_size, no_of_channels, h, w)