Going through the autodiff tutorials and other online discussions I came up with a function which specifically handles the multiplication of the two learnable parameters and returns the partial derivative with respect to each.
class Pmul(torch.autograd.Function):
@staticmethod
def forward(ctx, a, g):
ctx.save_for_backward(a,g)
return torch.mul(a,g)
@staticmethod
def backward(ctx, grad_output):
    a,g = ctx.saved_tensors
    da = grad_output*g 
    dg = grad_output*a
    return da, dg

With this I alias as pmul = Pmul.apply and then replace,
…+  self.a * self.g * torch.tanh(…)
with
…+ pmul(self.a,self.g) * torch.tanh(…)
I am testing it more but it seems to work.  Any feedback is much appreciated.
Thanks in advance!