docstr: compute and apply stats
  
  :param loss_sampled: ([TensorFlow Tensor]) the loss function output
  :param var_list: ([TensorFlow Tensor]) The parameters
  :return: (function) apply stats
docstr_tok: ["compute","and","apply","stats",":","param","loss_sampled",":","(","[","TensorFlow","Tensor","]",")","the","loss","function","output",":","param","var_list",":","(","[","TensorFlow","Tensor","]",")","The","parameters",":","return",":","(","function",")","apply","stats"]
code: def compute_and_apply_stats(self, loss_sampled, var_list=None):
      """
      compute and apply stats
  
      :param loss_sampled: ([TensorFlow Tensor]) the loss function output
      :param var_list: ([TensorFlow Tensor]) The parameters
      :return: (function) apply stats
      """
      varlist = var_list
      if varlist is None:
          varlist = tf.trainable_variables()
  
      stats = self.compute_stats(loss_sampled, var_list=varlist)
      return self.apply_stats(stats)
  
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 4 for calling the KfacOptimizer obj's underlying member method code with example usage: obj.compute_and_apply_stats(loss_sampled, var_list) and returns: self