docstr: apply the gradient
  
  :param grads: ([TensorFlow Tensor]) the gradient
  :return: (function, QueueRunner) train operation, queue operation runner
docstr_tok: ["apply","the","gradient",":","param","grads",":","(","[","TensorFlow","Tensor","]",")","the","gradient",":","return",":","(","function",",","QueueRunner",")","train","operation",",","queue","operation","runner"]
code: def apply_gradients(self, grads):
      """
      apply the gradient
  
      :param grads: ([TensorFlow Tensor]) the gradient
      :return: (function, QueueRunner) train operation, queue operation runner
      """
      cold_optim = tf.train.MomentumOptimizer(
          self._cold_lr, self._momentum
      )
  
      def _cold_sgd_start():
          sgd_grads, sgd_var = zip(*grads)
  
          if self.max_grad_norm is not None:
              sgd_grads, _ = tf.clip_by_global_norm(
                  sgd_grads, self.max_grad_norm
              )
  
          sgd_grads = list(zip(sgd_grads, sgd_var))
  
          sgd_step_op = tf.assign_add(self.sgd_step, 1)
          cold_optim_op = cold_optim.apply_gradients(sgd_grads)
          if KFAC_DEBUG:
              with tf.control_dependencies(
                  [sgd_step_op, cold_optim_op]
              ):
                  sgd_step_op = tf.Print(
                      sgd_step_op,
                      [
                          self.sgd_step,
                          tf.convert_to_tensor("doing cold sgd step"),
                      ],
                  )
          return tf.group(*[sgd_step_op, cold_optim_op])
  
      # remove unused variables
      grads = [(grad, var) for (grad, var) in grads if grad is not None]
  
      kfac_optim_op, queue_runner = self.apply_gradients_kfac(grads)
  
      def _warm_kfac_start():
          return kfac_optim_op
  
      return (
          tf.cond(
              tf.greater(self.sgd_step, self._cold_iter),
              _warm_kfac_start,
              _cold_sgd_start,
          ),
          queue_runner,
      )
  
imports: import re
  from functools import reduce
  import tensorflow
  import numpy
  from stable_baselines.acktr.kfac_utils import detect_min_val, factor_reshape, gmatmul
label_desc: Use image node_id 14 for calling the KfacOptimizer obj's underlying member method code with example usage: obj.apply_gradients(grads) and returns: tf,  queue_runner, tf, kfac_optim_op