class_docstr: BasicTimeProfiler can be used to profile the handlers,
  events, data loading and data processing times.
  
  Examples:
      .. code-block:: python
  
          from ignite.handlers import BasicTimeProfiler
  
          trainer = Engine(train_updater)
  
          # Create an object of the profiler and attach an engine to it
          profiler = BasicTimeProfiler()
          profiler.attach(trainer)
  
          @trainer.on(Events.EPOCH_COMPLETED)
          def log_intermediate_results():
              profiler.print_results(profiler.get_results())
  
          trainer.run(dataloader, max_epochs=3)
  
          profiler.write_results('path_to_dir/time_profiling.csv')
  
  .. versionadded:: 0.4.6
class_docstr_tok: ["BasicTimeProfiler","can","be","used","to","profile","the","handlers",",","events",",","data","loading","and","data","processing","times",".","Examples",":","..","code-block",":",":","python","from","ignite.handlers","import","BasicTimeProfiler","trainer","=","Engine","(","train_updater",")","#","Create","an","object","of","the","profiler","and","attach","an","engine","to","it","profiler","=","BasicTimeProfiler","(",")","profiler.attach","(","trainer",")","@","trainer.on","(","Events.EPOCH_COMPLETED",")","def","log_intermediate_results","(",")",":","profiler.print_results","(","profiler.get_results","(",")",")","trainer.run","(","dataloader",",","max_epochs=3",")","profiler.write_results","(","'path_to_dir\/time_profiling.csv","'",")","..","versionadded",":",":","0.4.6"]
code: def _as_first_started(self, engine: Engine) -> None:
      if hasattr(engine.state.dataloader, "__len__"):
          num_iters_per_epoch = len(engine.state.dataloader)  # type: ignore[arg-type]
      else:
          if engine.state.epoch_length is None:
              raise ValueError(
                  "As epoch_length is not set, we can not use BasicTimeProfiler in this case."
                  "Please, set trainer.run(..., epoch_length=epoch_length) in order to fix this."
              )
          num_iters_per_epoch = engine.state.epoch_length
  
      self.max_epochs = cast(int, engine.state.max_epochs)
      self.total_num_iters = self.max_epochs * num_iters_per_epoch
      self._reset(self.max_epochs, self.total_num_iters)
  
      self.event_handlers_names = {
          e: [
              h.__qualname__
              if hasattr(h, "__qualname__")
              else h.__class__.__name__
              for (h, _, _) in engine._event_handlers[e]
              if "BasicTimeProfiler."
              not in repr(
                  h
              )  # avoid adding internal handlers into output
          ]
          for e in Events
          if e not in self.events_to_ignore
      }
  
      # Setup all other handlers:
      engine._event_handlers[Events.STARTED].append(
          (self._as_last_started, (engine,), {})
      )
  
      for e, m in zip(self._events, self._fmethods):
          engine._event_handlers[e].insert(0, (m, (engine,), {}))
  
      for e, m in zip(self._events, self._lmethods):
          engine._event_handlers[e].append((m, (engine,), {}))
  
      # Let's go
      self._event_handlers_timer.reset()
  
imports: import functools
  from collections import OrderedDict
  from typing import Any, Callable, cast, Dict, List, Mapping, Sequence, Tuple, Union
  import torch
  from ignite.engine import Engine, EventEnum, Events
  from ignite.handlers.timing import Timer
label_desc: Use image node_id 3 for calling the BasicTimeProfiler obj's underlying member method code with example usage: obj._as_first_started(engine) without return types