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: Choose optimal unit.
docstr_tok: ["Choose","optimal","unit","."]
code: def _choose_unit(self, second):
      """Choose optimal unit."""
      factor = 1
      for unit in ["sec", "ms", "us"]:
          if second * factor >= 1:
              return factor, unit
          factor *= 1000.0
      return factor, "ns"
  
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 10 for calling the TimerHook obj's underlying member method code with example usage: obj._choose_unit(second) and returns: factor,  str, factor,  unit