Try 1:
def is_bad_grad(grad_output):
        if grad_output.requires_grad == True:
            print('grad_ouput have grad')
        grad_output = grad_output.data

Error:
if grad_output.requires_grad == True:
AttributeError: 'NoneType' object has no attribute 'requires_grad'

Try 2:
def is_bad_grad(grad_output):
        if grad_output.requires_grad == False:
            print('grad_ouput doesnt have grad')
        grad_output = grad_output.data

Error:
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
grad_ouput doesnt have grad
Traceback (most recent call last):
grad_ouput doesnt have grad
grad_ouput doesnt have grad
if grad_output.requires_grad == False:
AttributeError: 'NoneType' object has no attribute 'requires_grad'

Please give more details, so that i can debug this issue.