There are couple of problems.
First, I do not see that your env model is attached to any kind of optimizer. Questions that arise to me are: where is the forward pass of the model?  Are you sure the loss you apply at the end is connected to the computation graph of the env model in some way?
Second,
You have the context with torch.no_grad() which would disable gradient computation. When you are in training mode, it should not be used at all.
Hope this helps!