1.you need to run __init__ for  mod's base class
2. the parameters should be wrapped within a torch.nn.Parameter
3. torch.random is a module, say you are using torch.randn for normal distribution, then putting these together:
def __init__(self):
  super(mod,self).__init__()
  self.W = torch.nn.Parameter(torch.randn(3,4,5))
  self.W.requires_grad = True

then when you do loss.paramters() you can see W there.you can verify this by doing:
hex(id(next(loss.parameters()))) , hex(id(loss.W))