Why am I not able to calculate the gradient inspite of setting the requires_grad=True

Hi I am trying to create a diffractive neural network model using pytorch. Although I set the requires_grad=True for the parameters that I want to calculate the gradients, I am unable to get the gradients. It shows the gradients as none type. So I am unable to update the parameters. Can anyone please suggest me the possible reason for it?

Could you post a minimal and executable code snippet to reproduce the issue, please?