Thanks for the reply. No the backward is not a separate class. It is a function inside the model class. Here is how I define it:
Class myModel():
    def __init__(self, config):
         ....
    def forward(...):
        ....
    def backward(...):
        ....

And I call it this way:
outputs = model(....)
loss = outputs[0]  
if args.n_gpu > 1:
    loss = loss.mean()
model = model.backward(...)

but nn.DataParallel is not recognizing the backward and some other attributes without using module.