code: def _write_model_stats(self, iteration:int)->None:
          "Writes gradient statistics to Tensorboard."
          # We don't want to write stats when model is not iterated on and hence has zeroed out gradients
          gen_mode = self.learn.gan_trainer.gen_mode
          if gen_mode and not self.gen_stats_updated: self._write_gen_model_stats(iteration=iteration)
          if not gen_mode and not self.crit_stats_updated: self._write_critic_model_stats(iteration=iterationf _write_model_stats(self, iteration:int)->None:
          "Writes gradient statistics to Tensorboard."
          # We don't want to write stats when model is not iterated on and hence has zeroed out gradients
          gen_mode = self.learn.gan_trainer.gen_mode
          if gen_mode and not self.gen_stats_updated: self._write_gen_model_stats(iteration=iteration)
          if not gen_mode and not self.crit_stats_updated: self._write_critic_model_stats(iteration=iteration)
docs: Writes gradient statistics to Tensorboard.