code: def _clip_gradients(self, grads):
      if self.clipnorm and self.clipnorm > 0:
          clipped_grads = []
          for g in grads:
              if g is None:
                  clipped_grads.append(g)
              else:
                  clipped_grads.append(self._clip_by_norm(g))
          return clipped_grads
  
      if self.global_clipnorm and self.global_clipnorm > 0:
          return clip_by_global_norm(grads, self.global_clipnorm)
  
      if self.clipvalue and self.clipvalue > 0:
          clipped_grads = []
          for g in grads:
              if g is None:
                  clipped_grads.append(g)
              else:
                  clipped_grads.append(
                      ops.clip(g, -self.clipvalue, self.clipvalue)
                  )
          return clipped_grads
      return grads
  
imports: import re
  import warnings
  import numpy
  from keras import backend
  from keras import initializers
  from keras import ops
  from keras.optimizers.schedules import learning_rate_schedule
  from keras.saving import serialization_lib
  from keras.utils import tracking
  from keras.utils.naming import auto_name
label_desc: Use image node_id 29 for calling the BaseOptimizer obj's underlying member method code with example usage: obj._clip_gradients(grads) and returns: grads, clipped_grads, clip_by_global_norm, clipped_grads