Hi,
theta is of shape [B, 1] here right? So since it’s the input you ask gradient for, it’s not surprising it has the same size.
Keep in mind that autograd.grad does vector jacobian product. Where the vector is the grad_outputs that you provided.