code: def mimic_adam_with_adafactor(hparams):
    
    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"
docs: 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