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 fetch the aggregated profiler results after the engine is run
  
  .. code-block:: python
  
      results = profiler.get_results()
code: def get_results(
      self,
  ) -> List[
      List[
          Union[str, float, Tuple[Union[str, float], Union[str, float]]]
      ]
  ]:
      """
      Method to fetch the aggregated profiler results after the engine is run
  
      .. code-block:: python
  
          results = profiler.get_results()
  
      """
      total_eh_time = sum(
          [
              sum(self.event_handlers_times[e][h])
              for e in self.event_handlers_times
              for h in self.event_handlers_times[e]
          ]
      )
      total_eh_time = round(float(total_eh_time), 5)
  
      def compute_basic_stats(
          times: Union[Sequence, torch.Tensor]
      ) -> List[
          Union[str, float, Tuple[Union[str, float], Union[str, float]]]
      ]:
          data = torch.as_tensor(times, dtype=torch.float32)
          # compute on non-zero data:
          data = data[data > 0]
          total: Union[str, float] = (
              round(torch.sum(data).item(), 5)
              if len(data) > 0
              else "not triggered"
          )
          min_index: Tuple[Union[str, float], Union[str, float]] = (
              "None",
              "None",
          )
          max_index: Tuple[Union[str, float], Union[str, float]] = (
              "None",
              "None",
          )
          mean: Union[str, float] = "None"
          std: Union[str, float] = "None"
          if len(data) > 0:
              min_index = (
                  round(torch.min(data).item(), 5),
                  torch.argmin(data).item(),
              )
              max_index = (
                  round(torch.max(data).item(), 5),
                  torch.argmax(data).item(),
              )
              mean = round(torch.mean(data).item(), 5)
              if len(data) > 1:
                  std = round(torch.std(data).item(), 5)
          return [total, min_index, max_index, mean, std]
  
      event_handler_stats = [
          [
              h,
              getattr(e, "name", str(e)),
              *compute_basic_stats(
                  torch.tensor(
                      self.event_handlers_times[e][h],
                      dtype=torch.float32,
                  )
              ),
          ]
          for e in self.event_handlers_times
          for h in self.event_handlers_times[e]
      ]
      event_handler_stats.append(
          ["Total", "", total_eh_time, "", "", "", ""]
      )
      event_handler_stats.append(
          [
              "Processing",
              "None",
              *compute_basic_stats(self.processing_times),
          ]
      )
      event_handler_stats.append(
          [
              "Dataflow",
              "None",
              *compute_basic_stats(self.dataflow_times),
          ]
      )
  
      return event_handler_stats
  
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 11 for calling the HandlersTimeProfiler obj's underlying member method code with example usage: obj.get_results() and returns: event_handler_stats, list