def grad_ignore_value_(parameters: _tensor_or_tensors, clip_value: float) -> None:
    """
    **Overview**:
        Implementation of grad_ignore_value <link https://github.com/opendilab/DI-engine/blob/2ab7c44a64329fb90fa877e6070bc76bb6fdb31e/ding/torch_utils/optimizer_helper.py#L77 link>
        Different from ``grad_clip_value`` , ``grad_ignore_value`` **ignore**: all the gradients when any of them exceeds the specified threshold, instead of cliping them to the threshold.
    """
    # Save the parameters with non-empty gradient into a list.
    if isinstance(parameters, torch.Tensor):
        parameters = [parameters]
    parameters = list(filter(lambda p: p.grad is not None, parameters))
    # Convert clip_value to float.
    clip_value = float(clip_value)
    flag = False
    # Check if there is any gradient that exceeds the clip_value.
    for p in parameters:
        val = p.grad.data.abs().max()
        if val >= clip_value:
            flag = True
            break
    # If there exists a gradient that exceeds the clip_value, then clip all the gradients to zero.
    if flag:
        for p in parameters:
            p.grad.data.zero_()

    **Overview**:
        Implementation of grad_ignore_value <link https://github.com/opendilab/DI-engine/blob/2ab7c44a64329fb90fa877e6070bc76bb6fdb31e/ding/torch_utils/optimizer_helper.py#L77 link>
        Different from ``grad_clip_value`` , ``grad_ignore_value`` **ignore**: all the gradients when any of them exceeds the specified threshold, instead of cliping them to the threshold.
    
chapter7_tricks/grad_ignore.py