class_docstr: HandlersTimeProfiler can be used to profile the handlers,
  data loading and data processing times. Custom events are also
  profiled by this profiler
  
  Examples:
      .. code-block:: python
  
          from ignite.handlers import HandlersTimeProfiler
  
          trainer = Engine(train_updater)
  
          # Create an object of the profiler and attach an engine to it
          profiler = HandlersTimeProfiler()
          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: ["HandlersTimeProfiler","can","be","used","to","profile","the","handlers",",","data","loading","and","data","processing","times",".","Custom","events","are","also","profiled","by","this","profiler","Examples",":","..","code-block",":",":","python","from","ignite.handlers","import","HandlersTimeProfiler","trainer","=","Engine","(","train_updater",")","#","Create","an","object","of","the","profiler","and","attach","an","engine","to","it","profiler","=","HandlersTimeProfiler","(",")","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
  
          -----------------------------------------  -----------------------  -------------- ...
          Handler                                    Event Name                     Total(s)
          -----------------------------------------  -----------------------  --------------
          run.<locals>.log_training_results          EPOCH_COMPLETED                19.43245
          run.<locals>.log_validation_results        EPOCH_COMPLETED                 2.55271
          run.<locals>.log_time                      EPOCH_COMPLETED                 0.00049
          run.<locals>.log_intermediate_results      EPOCH_COMPLETED                 0.00106
          run.<locals>.log_training_loss             ITERATION_COMPLETED               0.059
          run.<locals>.log_time                      COMPLETED                 not triggered
          -----------------------------------------  -----------------------  --------------
          Total                                                                     22.04571
          -----------------------------------------  -----------------------  --------------
          Processing took total 11.29543s [min/index: 0.00393s/1875, max/index: 0.00784s/0,
           mean: 0.00602s, std: 0.00034s]
          Dataflow took total 16.24365s [min/index: 0.00533s/1874, max/index: 0.01129s/937,
           mean: 0.00866s, std: 0.00113s]
code: def print_results(results: List[List[Union[str, float]]]) -> None:
      """
      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
  
              -----------------------------------------  -----------------------  -------------- ...
              Handler                                    Event Name                     Total(s)
              -----------------------------------------  -----------------------  --------------
              run.<locals>.log_training_results          EPOCH_COMPLETED                19.43245
              run.<locals>.log_validation_results        EPOCH_COMPLETED                 2.55271
              run.<locals>.log_time                      EPOCH_COMPLETED                 0.00049
              run.<locals>.log_intermediate_results      EPOCH_COMPLETED                 0.00106
              run.<locals>.log_training_loss             ITERATION_COMPLETED               0.059
              run.<locals>.log_time                      COMPLETED                 not triggered
              -----------------------------------------  -----------------------  --------------
              Total                                                                     22.04571
              -----------------------------------------  -----------------------  --------------
              Processing took total 11.29543s [min/index: 0.00393s/1875, max/index: 0.00784s/0,
               mean: 0.00602s, std: 0.00034s]
              Dataflow took total 16.24365s [min/index: 0.00533s/1874, max/index: 0.01129s/937,
               mean: 0.00866s, std: 0.00113s]
  
      """
      # adopted implementation of torch.autograd.profiler.build_table
      handler_column_width = max([len(item[0]) for item in results]) + 4  # type: ignore[arg-type]
      event_column_width = max([len(item[1]) for item in results]) + 4  # type: ignore[arg-type]
  
      DEFAULT_COLUMN_WIDTH = 14
  
      headers = [
          "Handler",
          "Event Name",
          "Total(s)",
          "Min(s)/IDX",
          "Max(s)/IDX",
          "Mean(s)",
          "Std(s)",
      ]
  
      # Have to use a list because nonlocal is Py3 only...
      SPACING_SIZE = 2
      row_format_lst = [""]
      header_sep_lst = [""]
      line_length_lst = [-SPACING_SIZE]
  
      def add_column(padding: int, text_dir: str = ">") -> None:
          row_format_lst[0] += (
              "{: "
              + text_dir
              + str(padding)
              + "}"
              + (" " * SPACING_SIZE)
          )
          header_sep_lst[0] += "-" * padding + (" " * SPACING_SIZE)
          line_length_lst[0] += padding + SPACING_SIZE
  
      add_column(handler_column_width, text_dir="<")
      add_column(event_column_width, text_dir="<")
      for _ in headers[2:]:
          add_column(DEFAULT_COLUMN_WIDTH)
  
      row_format = row_format_lst[0]
      header_sep = header_sep_lst[0]
  
      result = []
  
      def append(s: str) -> None:
          result.append(s)
          result.append("\n")
  
      result.append("\n")
      append(header_sep)
      append(row_format.format(*headers))
      append(header_sep)
  
      for row in results[:-3]:
          # format min/idx and max/idx
          row[3] = "{}/{}".format(*row[3])  # type: ignore[misc]
          row[4] = "{}/{}".format(*row[4])  # type: ignore[misc]
  
          append(row_format.format(*row))
  
      append(header_sep)
      # print total handlers time row
      append(row_format.format(*results[-3]))
      append(header_sep)
  
      summary_format = "{} took total {}s [min/index: {}, max/index: {}, mean: {}s, std: {}s]"
      for row in results[-2:]:
          row[3] = "{}s/{}".format(*row[3])  # type: ignore[misc]
          row[4] = "{}s/{}".format(*row[4])  # type: ignore[misc]
          del row[1]
          append(summary_format.format(*row))
      print("".join(result))
  
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 13 for calling the HandlersTimeProfiler obj's underlying member method code with example usage: obj.print_results(results) without return types