docstr: Test train records time in the iteration_timer
docstr_tok: ["Test","train","records","time","in","the","iteration_timer"]
code: def test_train_uses_iteration_timer(self) -> None:
      """
      Test train records time in the iteration_timer
      """
      input_dim = 2
      dataset_len = 10
      batch_size = 2
      max_steps_per_epoch = 1
      max_epochs = 1
  
      my_unit = DummyTrainUnit(2)
      dataloader = generate_random_dataloader(
          dataset_len, input_dim, batch_size
      )
  
      def assertInTest(key: str, mapping: Mapping[str, Any]) -> None:
          self.assertIn(key, mapping)
  
      class CheckTimerUsedCallback(Callback):
          def on_train_end(
              self, state: State, unit: TTrainUnit
          ) -> None:
              assertInTest(
                  "data_wait_time",
                  state.train_state.iteration_timer.recorded_durations,
              )
              assertInTest(
                  "train_iteration_time",
                  state.train_state.iteration_timer.recorded_durations,
              )
  
      check_timer_callback = CheckTimerUsedCallback()
  
      train(
          my_unit,
          dataloader,
          max_epochs=max_epochs,
          max_steps_per_epoch=max_steps_per_epoch,
          callbacks=[check_timer_callback],
      )
  
imports: import unittest
  from typing import Any, Iterator, Mapping, Tuple
  from unittest.mock import MagicMock
  import torch
  from torch import nn
  from torchtnt.framework._test_utils import DummyTrainUnit, generate_random_dataloader
  from torchtnt.framework.callback import Callback
  from torchtnt.framework.state import State
  from torchtnt.framework.train import train
  from torchtnt.framework.unit import TrainUnit, TTrainUnit
  from torchtnt.utils.timer import Timer
label_desc: Use image node_id 5 for calling the TrainTest obj's underlying member method code with example usage: obj.test_train_uses_iteration_timer() without return types