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 store the unaggregated profiling results to a csv file
  
  Args:
      output_path: file output path containing a filename
  
  .. code-block:: python
  
      profiler.write_results('path_to_dir/awesome_filename.csv')
  
  Examples:
      .. code-block:: text
  
          -----------------------------------------------------------------
          # processing_stats dataflow_stats training.<locals>.log_elapsed_time (EPOCH_COMPLETED) ...
          1     0.00003         0.252387                          0.125676
          2     0.00029         0.252342                          0.125123
code: def write_results(self, output_path: str) -> None:
      """
      Method to store the unaggregated profiling results to a csv file
  
      Args:
          output_path: file output path containing a filename
  
      .. code-block:: python
  
          profiler.write_results('path_to_dir/awesome_filename.csv')
  
      Examples:
          .. code-block:: text
  
              -----------------------------------------------------------------
              # processing_stats dataflow_stats training.<locals>.log_elapsed_time (EPOCH_COMPLETED) ...
              1     0.00003         0.252387                          0.125676
              2     0.00029         0.252342                          0.125123
  
      """
      try:
          import pandas as pd
      except ImportError:
          raise ModuleNotFoundError(
              "Need pandas to write results as files"
          )
  
      processing_stats = torch.tensor(
          self.processing_times, dtype=torch.float32
      )
      dataflow_stats = torch.tensor(
          self.dataflow_times, dtype=torch.float32
      )
  
      cols = [processing_stats, dataflow_stats]
      headers = ["processing_stats", "dataflow_stats"]
      for e in self.event_handlers_times:
          for h in self.event_handlers_times[e]:
              headers.append(f"{h} ({getattr(e, 'name', str(e))})")
              cols.append(
                  torch.tensor(
                      self.event_handlers_times[e][h],
                      dtype=torch.float32,
                  )
              )
      # Determine maximum length
      max_len = max([x.numel() for x in cols])
  
      count_col = torch.arange(max_len, dtype=torch.float32) + 1
      cols.insert(0, count_col)
      headers.insert(0, "#")
  
      # pad all tensors to have same length
      cols = [
          torch.nn.functional.pad(
              x, pad=(0, max_len - x.numel()), mode="constant", value=0
          )
          for x in cols
      ]
  
      results_dump = torch.stack(cols, dim=1).numpy()
  
      results_df = pd.DataFrame(data=results_dump, columns=headers)
      results_df.to_csv(output_path, index=False)
  
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 12 for calling the HandlersTimeProfiler obj's underlying member method code with example usage: obj.write_results(output_path) without return types