Hy Kunal, Sure.
First you need to extend your class from torch.nn.Module to create model class.



 Kunal_Dapse:

class RBM():


class RBM(nn.Module):
       def __init__(self):
              super(RBM,self).__init()
              //code 
              self.W = nn.Parameter(torch.randn(nh,nv))
              self.v_bias = nn.Parameter(torch.randn(1,nh))
              self.h_bias = nn.Parameter(torch.zeros(1,nv))
      def forward(self,input):
              self.layer(input)

You can define the rest of the function inside the class and call them in forward function.