class_docstr: Implements APPO loss / update logic on top of ImpalaTfLearner.
class_docstr_tok: ["Implements","APPO","loss","\/","update","logic","on","top","of","ImpalaTfLearner","."]
code: def _update_module_kl_coeff(
      self, module_id: ModuleID, config: APPOConfig, sampled_kl: float
  ) -> Dict[str, Any]:
      # Update the current KL value based on the recently measured value.
      # Increase.
      kl_coeff_var = self.curr_kl_coeffs_per_module[module_id]
  
      if sampled_kl > 2.0 * config.kl_target:
          # TODO (Kourosh) why not *2.0?
          kl_coeff_var.assign(kl_coeff_var * 1.5)
      # Decrease.
      elif sampled_kl < 0.5 * config.kl_target:
          kl_coeff_var.assign(kl_coeff_var * 0.5)
  
      return {LEARNER_RESULTS_CURR_KL_COEFF_KEY: kl_coeff_var.numpy()}
  
file_path: ray/rllib/algorithms/appo/tf/appo_tf_learner.py
imports: from typing import Any, Dict
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.algorithms.appo.appo import APPOConfig, LEARNER_RESULTS_CURR_KL_COEFF_KEY, LEARNER_RESULTS_KL_KEY, OLD_ACTION_DIST_LOGITS_KEY
  from ray.rllib.algorithms.appo.appo_learner import AppoLearner
  from ray.rllib.algorithms.impala.tf.vtrace_tf_v2 import make_time_major, vtrace_tf2
  from ray.rllib.core.learner.learner import POLICY_LOSS_KEY, VF_LOSS_KEY, ENTROPY_KEY
  from ray.rllib.core.learner.tf.tf_learner import TfLearner
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.nested_dict import NestedDict
  from ray.rllib.utils.typing import ModuleID, TensorType
label_desc: Use image node_id 3 for calling the APPOTfLearner obj's underlying member method code with example usage: obj._update_module_kl_coeff(module_id, config, sampled_kl) and returns: dict