<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Define the network
Step1:  You just have to define the forward function, and the backward function (where the gradients are computed) is automatically defined for you using autograd. You can use any of the Tensor operations in the forward function.
The learnable parameteres of a model are returns by net.parameters()
Step2:  The input to the forward is an autograd.Variable, and so is the output. NOTE
Step3:  Zero the gradient buffers of all parameters and backprops with random gradients
<ASSISTANT_TASK:>
Python Code:
import torch # PyTorch base
from torch.autograd import Variable # Tensor class w gradients
import torch.nn as nn # modules, layers, loss fns
import torch.nn.functional as F # Conv,Pool,Loss,Actvn,Nrmlz fns from here
class Net(nn.Module):
    
    def __init__(self):
        super(Net, self).__init__()
        # 1 input image channel, 6 output channels, 5x5 square convolution
        # Kernel
        self.conv1 = nn.Conv2d(1, 6, 5)
        self.conv2 = nn.Conv2d(6, 16, 5)
        # an Affine Operation: y = Wx + b
        self.fc1 = nn.Linear(16*5*5, 120) # Linear is Dense/Fully-Connected
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)
        
    def forward(self, x):
        # Max pooling over a (2, 2) window
        # x = torch.nn.functional.max_pool2d(torch.nn.functional.relu(self.conv1(x)), (2,2))
        x = F.max_pool2d(F.relu(self.conv1(x)), (2,2))
        # If size is a square you can only specify a single number
        x = F.max_pool2d(F.relu(self.conv2(x)), 2)
        x = x.view(-1, self.num_flat_features(x))
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x
    
    def num_flat_features(self, x):
        size = x.size()[1:]  # all dimensions except the batch dimension
        num_features = 1
        for s in size:
            num_features *= s
        return num_features
net = Net()
print(net)
Explanation: Define the network:
End of explanation
pars = list(net.parameters())
print(len(pars))
print(pars[0].size())  # conv1's .weight
Explanation: You just have to define the forward function, and the backward function (where the gradients are computed) is automatically defined for you using autograd. You can use any of the Tensor operations in the forward function.
The learnable parameteres of a model are returns by net.parameters()
End of explanation
input = Variable(torch.randn(1, 1, 32, 32))
out = net(input)
print(out)
Explanation: The input to the forward is an autograd.Variable, and so is the output. NOTE: Expected input size to this net(LeNet) is 32x32. To use this net on MNIST dataset, please resize the images from the dataset to 32x32.
End of explanation
net.zero_grad()
out.backward(torch.randn(1, 10))
Explanation: Zero the gradient buffers of all parameters and backprops with random gradients:
End of explanation
<END_TASK>