code: def update_kl_coefficient(self):
      # John Schulman takes the mean kl divergence only over the last epoch which is strange but we will follow
      # his implementation for now because we know it works well
      screen.log_title(
          "KL = {}".format(
              self.total_kl_divergence_during_training_process
          )
      )
  
      # update kl coefficient
      kl_target = self.ap.algorithm.target_kl_divergence
      kl_coefficient = self.networks[
          "actor"
      ].online_network.get_variable_value(
          self.networks["actor"]
          .online_network.output_heads[0]
          .kl_coefficient
      )
      new_kl_coefficient = kl_coefficient
      if (
          self.total_kl_divergence_during_training_process
          > 1.3 * kl_target
      ):
          # kl too high => increase regularization
          new_kl_coefficient *= 1.5
      elif (
          self.total_kl_divergence_during_training_process
          < 0.7 * kl_target
      ):
          # kl too low => decrease regularization
          new_kl_coefficient /= 1.5
  
      # update the kl coefficient variable
      if kl_coefficient != new_kl_coefficient:
          self.networks["actor"].online_network.set_variable_value(
              self.networks["actor"]
              .online_network.output_heads[0]
              .assign_kl_coefficient,
              new_kl_coefficient,
              self.networks["actor"]
              .online_network.output_heads[0]
              .kl_coefficient_ph,
          )
  
      screen.log_title(
          "KL penalty coefficient change = {} -> {}".format(
              kl_coefficient, new_kl_coefficient
          )
      )
  
imports: import copy
  from collections import OrderedDict
  from typing import Union
  import numpy
  from rl_coach.agents.actor_critic_agent import ActorCriticAgent
  from rl_coach.agents.policy_optimization_agent import PolicyGradientRescaler
  from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
  from rl_coach.architectures.head_parameters import PPOHeadParameters, VHeadParameters
  from rl_coach.architectures.middleware_parameters import FCMiddlewareParameters
  from rl_coach.base_parameters import AlgorithmParameters, NetworkParameters, AgentParameters, DistributedTaskParameters
  from rl_coach.core_types import EnvironmentSteps, Batch
  from rl_coach.exploration_policies.additive_noise import AdditiveNoiseParameters
  from rl_coach.exploration_policies.categorical import CategoricalParameters
  from rl_coach.logger import screen
  from rl_coach.memories.episodic.episodic_experience_replay import EpisodicExperienceReplayParameters
  from rl_coach.spaces import DiscreteActionSpace, BoxActionSpace
  from rl_coach.utils import force_list
label_desc: Use image node_id 7 for calling the PPOAgent obj's underlying member method code with example usage: obj.update_kl_coefficient() without return types