code: def mimic_adam_with_adafactor(hparams):
      """Switch from Adam to Adafactor, approximating the behavior of Adam.
  
      Some minor things may be different, like epsilon and beta1 correction.
  
      Args:
        hparams: model hyperparameters where "adam" in hparams.optimizer
      """
      assert "adam" in hparams.optimizer
      hparams.optimizer = "adafactor"
      hparams.optimizer_adafactor_beta1 = hparams.optimizer_adam_beta1
      hparams.optimizer_adafactor_beta2 = hparams.optimizer_adam_beta2
      hparams.optimizer_adafactor_multiply_by_parameter_scale = False
      hparams.optimizer_adafactor_factored = False
      hparams.optimizer_adafactor_clipping_threshold = None
      hparams.optimizer_adafactor_decay_type = "adam"
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import registry
label_desc: Use image node_id 1 for calling a global function with example usage: mimic_adam_with_adafactor(hparams) without return types