class_docstr: Hook to log metric by step.
  
  Args:
      priority (int, optional): Priority in the printing, hooks with small priority will be printed in front,
          defaults to 10. If different hooks share same priority, the order of printing would
          depend on the hooks order in the hook list.
class_docstr_tok: ["Hook","to","log","metric","by","step",".","Args",":","priority","(","int",",","optional",")",":","Priority","in","the","printing",",","hooks","with","small","priority","will","be","printed","in","front",",","defaults","to","10",".","If","different","hooks","share","same","priority",",","the","order","of","printing","would","depend","on","the","hooks","order","in","the","hook","list","."]
code: def after_train_iter(self, trainer, *args):
      trainer.states["step_metrics"] = dict()
      for metric_name, metric_calculator in trainer.states["metrics"][
          "train"
      ].items():
          if isinstance(metric_calculator, ThroughputMetric):
              trainer.states["step_metrics"][
                  metric_name.lower()
              ] = metric_calculator.get_last_step_info()
          else:
              trainer.states["step_metrics"][
                  metric_name.lower()
              ] = metric_calculator.get_last_step_value()
  
imports: import os
  import os.path
  from typing import List
  from colossalai.legacy.context import ParallelMode
  from colossalai.legacy.core import global_context
  from colossalai.legacy.registry import HOOKS
  from colossalai.legacy.trainer.hooks._metric_hook import ThroughputMetric
  from colossalai.legacy.utils import is_dp_rank_0, is_no_pp_or_last_stage, is_tp_rank_0, report_memory_usage
  from colossalai.logging import DistributedLogger
  from colossalai.utils import MultiTimer
  from ._base_hook import BaseHook
  from ._commons_ import _format_number
label_desc: Use image node_id 2 for calling the LogMetricByStepHook obj's underlying member method code with example usage: obj.after_train_iter(trainer) without return types