def has_overflow(self, params):
is_not_finite = <NUM_LIT:0><EOL>for param in params:<EOL><INDENT>if param.grad_req != '<STR_LIT:null>':<EOL><INDENT>grad = param.list_grad()[<NUM_LIT:0>]<EOL>is_not_finite += mx.nd.contrib.isnan(grad).sum()<EOL>is_not_finite += mx.nd.contrib.isinf(grad).sum()<EOL><DEDENT><DEDENT>if is_not_finite == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>else:<EOL><INDENT>return True<EOL><DEDENT>
detect inf and nan