Implement gradient clipping by value. Given a list of gradients, clip each element so that its value falls within the range [-clip_value, clip_value].
import numpy as np
def gradient_clipping_by_value(gradients: list[np.ndarray], clip_value: float) -> list[np.ndarray]:
return [np.clip(g, -clip_value, clip_value) for g in gradients]np.clip.