class_docstr: Function hook for measuring elapsed time of functions.
  
  Example:
      Code example::
  
          from chainer.function_hooks import TimerHook
          hook = TimerHook()
          with hook:
              trainer.run()
          hook.print_report()
  
      Output example::
  
                 FunctionName  ElapsedTime  Occurrence
               LinearFunction      1.24sec        3900
                         ReLU      0.59sec        2600
          SoftmaxCrossEntropy      0.82sec        1300
                     Accuracy      0.18sec         700
  
      where *FunctionName* is the name of function that calls the hook,
      and *ElapsedTime* is the elapsed time the function consumed,
      and *Occurrence* is the number of calls.
  Attributes:
      call_history: List of measurement results. It consists of pairs of
          the name of the function that calls this hook and the elapsed time
          the function consumes.
class_docstr_tok: ["Function","hook","for","measuring","elapsed","time","of","functions",".","Example",":","Code","example",":",":","from","chainer.function_hooks","import","TimerHook","hook","=","TimerHook","(",")","with","hook",":","trainer.run","(",")","hook.print_report","(",")","Output","example",":",":","FunctionName","ElapsedTime","Occurrence","LinearFunction","1.24sec","3900","ReLU","0.59sec","2600","SoftmaxCrossEntropy","0.82sec","1300","Accuracy","0.18sec","700","where","*","FunctionName","*","is","the","name","of","function","that","calls","the","hook",",","and","*","ElapsedTime","*","is","the","elapsed","time","the","function","consumed",",","and","*","Occurrence","*","is","the","number","of","calls",".","Attributes",":","call_history",":","List","of","measurement","results",".","It","consists","of","pairs","of","the","name","of","the","function","that","calls","this","hook","and","the","elapsed","time","the","function","consumes","."]
docstr: Prints a summary report of time profiling in functions.
  
  Args:
      unit (str): Supplementary units used for computational times.
          `sec`, `ms`, `us`, `ns`, `auto`(default) and `auto_foreach`
          are supported. If `auto`, units of times are aligned to the
          largest, and if `auto_foreach`, units of times are adjusted for
          each element.
docstr_tok: ["Prints","a","summary","report","of","time","profiling","in","functions",".","Args",":","unit","(","str",")",":","Supplementary","units","used","for","computational","times",".","`","sec","`",",","`","ms","`",",","`","us","`",",","`","ns","`",",","`","auto","`","(","default",")","and","`","auto_foreach","`","are","supported",".","If","`","auto","`",",","units","of","times","are","aligned","to","the","largest",",","and","if","`","auto_foreach","`",",","units","of","times","are","adjusted","for","each","element","."]
code: def print_report(self, unit="auto", file=sys.stdout):
      """Prints a summary report of time profiling in functions.
  
      Args:
          unit (str): Supplementary units used for computational times.
              `sec`, `ms`, `us`, `ns`, `auto`(default) and `auto_foreach`
              are supported. If `auto`, units of times are aligned to the
              largest, and if `auto_foreach`, units of times are adjusted for
              each element.
      """
      entries = [["FunctionName", "ElapsedTime", "Occurrence"]]
      auto_foreach = unit == "auto_foreach"
      if unit == "auto":
          max_time = max(
              record["elapsed_time"]
              for record in self.summary().values()
          )
          factor, unit = self._choose_unit(max_time)
      elif unit != "auto_foreach":
          factor = self.table[unit]
      for function_name, record in self.summary().items():
          second = record["elapsed_time"]
          if auto_foreach:
              factor, unit = self._choose_unit(second)
          elapsed_time = "%3.2f%s" % (second * factor, unit)
          occurrence = str(record["occurrence"])
          entries.append([function_name, elapsed_time, occurrence])
      entry_widths = []
      entry_widths.append(max(len(f) for f, _, _ in entries))
      entry_widths.append(max(len(e) for _, e, _ in entries))
      entry_widths.append(max(len(o) for _, _, o in entries))
      template = "  ".join("{:>%d}" % w for w in entry_widths)
      for function_name, elapsed_time, occurrence in entries:
          line = template.format(
              function_name, elapsed_time, occurrence
          )
          file.write(line)
          file.write("\n")
      if hasattr(file, "flush"):
          file.flush()
  
imports: import os
  import sys
  import time
  import numpy
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_hook
label_desc: Use image node_id 11 for calling the TimerHook obj's underlying member method code with example usage: obj.print_report(unit, file) without return types