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"]
docstr: Method to print the aggregated results from the profiler
  
  Args:
      results: the aggregated results from the profiler
  
  .. code-block:: python
  
      profiler.print_results(results)
  
  Examples:
      .. code-block:: text
  
           ----------------------------------------------------
          | Time profiling stats (in seconds):                 |
           ----------------------------------------------------
          total  |  min/index  |  max/index  |  mean  |  std
  
          Processing function:
          157.46292 | 0.01452/1501 | 0.26905/0 | 0.07730 | 0.01258
  
          Dataflow:
          6.11384 | 0.00008/1935 | 0.28461/1551 | 0.00300 | 0.02693
  
          Event handlers:
          2.82721
  
          - Events.STARTED: []
          0.00000
  
          - Events.EPOCH_STARTED: []
          0.00006 | 0.00000/0 | 0.00000/17 | 0.00000 | 0.00000
  
          - Events.ITERATION_STARTED: ['PiecewiseLinear']
          0.03482 | 0.00001/188 | 0.00018/679 | 0.00002 | 0.00001
  
          - Events.ITERATION_COMPLETED: ['TerminateOnNan']
          0.20037 | 0.00006/866 | 0.00089/1943 | 0.00010 | 0.00003
  
          - Events.EPOCH_COMPLETED: ['empty_cuda_cache', 'training.<locals>.log_elapsed_time', ]
          2.57860 | 0.11529/0 | 0.14977/13 | 0.12893 | 0.00790
  
          - Events.COMPLETED: []
          not yet triggered
code: def print_results(results: Dict) -> str:
      """
      Method to print the aggregated results from the profiler
  
      Args:
          results: the aggregated results from the profiler
  
      .. code-block:: python
  
          profiler.print_results(results)
  
      Examples:
          .. code-block:: text
  
               ----------------------------------------------------
              | Time profiling stats (in seconds):                 |
               ----------------------------------------------------
              total  |  min/index  |  max/index  |  mean  |  std
  
              Processing function:
              157.46292 | 0.01452/1501 | 0.26905/0 | 0.07730 | 0.01258
  
              Dataflow:
              6.11384 | 0.00008/1935 | 0.28461/1551 | 0.00300 | 0.02693
  
              Event handlers:
              2.82721
  
              - Events.STARTED: []
              0.00000
  
              - Events.EPOCH_STARTED: []
              0.00006 | 0.00000/0 | 0.00000/17 | 0.00000 | 0.00000
  
              - Events.ITERATION_STARTED: ['PiecewiseLinear']
              0.03482 | 0.00001/188 | 0.00018/679 | 0.00002 | 0.00001
  
              - Events.ITERATION_COMPLETED: ['TerminateOnNan']
              0.20037 | 0.00006/866 | 0.00089/1943 | 0.00010 | 0.00003
  
              - Events.EPOCH_COMPLETED: ['empty_cuda_cache', 'training.<locals>.log_elapsed_time', ]
              2.57860 | 0.11529/0 | 0.14977/13 | 0.12893 | 0.00790
  
              - Events.COMPLETED: []
              not yet triggered
  
      """
  
      def to_str(v: Union[str, tuple]) -> str:
          if isinstance(v, str):
              return v
          elif isinstance(v, tuple):
              return f"{v[0]:.5f}/{v[1]}"
          return f"{v:.5f}"
  
      def odict_to_str(d: Mapping) -> str:
          out = " | ".join([to_str(v) for v in d.values()])
          return out
  
      others = {
          k: odict_to_str(v) if isinstance(v, OrderedDict) else v
          for k, v in results["event_handlers_stats"].items()
      }
  
      others.update(results["event_handlers_names"])
  
      output_message = """
   ----------------------------------------------------
  | Time profiling stats (in seconds):                 |
   ----------------------------------------------------
  total  |  min/index  |  max/index  |  mean  |  std
  
  Processing function:
  {processing_stats}
  
  Dataflow:
  {dataflow_stats}
  
  Event handlers:
  {total_time:.5f}
  
  - Events.STARTED: {STARTED_names}
  {STARTED}
  
  - Events.EPOCH_STARTED: {EPOCH_STARTED_names}
  {EPOCH_STARTED}
  
  - Events.ITERATION_STARTED: {ITERATION_STARTED_names}
  {ITERATION_STARTED}
  
  - Events.ITERATION_COMPLETED: {ITERATION_COMPLETED_names}
  {ITERATION_COMPLETED}
  
  - Events.EPOCH_COMPLETED: {EPOCH_COMPLETED_names}
  {EPOCH_COMPLETED}
  
  - Events.COMPLETED: {COMPLETED_names}
  {COMPLETED}
  """.format(
          processing_stats=odict_to_str(results["processing_stats"]),
          dataflow_stats=odict_to_str(results["dataflow_stats"]),
          **others,
      )
      print(output_message)
      return output_message
  
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 23 for calling the BasicTimeProfiler obj's underlying member method code with example usage: obj.print_results(results) and returns: output_message, v, out, v, v, str, v