def is_bad_grad(grad_output):
    """Checks if gradient is too big

    Parameters
    ----------
    grad_output
        The gradient you got back during back-propagation.

    Returns
    -------
    bool
        True if gradient is bad, False otherwise.

    """
    grad_output = grad_output.data
    return grad_output.ne(grad_output).any() or grad_output.gt(1e6).any()