Hi,
Right, the gist was made for an older version of pytorch where the create_graph flag was slightly different. In particular, it was not required to set it if projection was requirering gradients.
So yes you need to set it in the first backward, to be allow to call grad on the result.
You only need to set it in the second backward if you want to be able to call grad on the d_dot_b.