class_docstr: Timer for PyTorch code Comes in the form of a contextmanager:
  
  Example:
  >>> timer = Timer()
  ... for i in range(10):
  ...     with timer("expensive operation"):
  ...         x = torch.randn(100)
  ... print(timer.summary())
class_docstr_tok: ["Timer","for","PyTorch","code","Comes","in","the","form","of","a","contextmanager",":","Example",":",">",">",">","timer","=","Timer","(",")","...","for","i","in","range","(","10",")",":","...","with","timer","(","``","expensive","operation","''",")",":","...","x","=","torch.randn","(","100",")","...","print","(","timer.summary","(",")",")"]
code: def __init__(self, verbosity_level=1, skip_first=True, on_cuda=True):
      self.verbosity_level = verbosity_level
      # self.log_fn = log_fn if log_fn is not None else self._default_log_fn
      self.skip_first = skip_first
      self.cuda_available = torch.cuda.is_available() and on_cuda
  
      self.reset()
  
file_path: gluonts/src/gluonts/nursery/SCott/trainers/timer.py
imports: import time
  from contextlib import contextmanager
  from io import StringIO
  import numpy
  import torch
label_desc: Use image node_id 1 to create a new Timer object  with example: obj = Timer(verbosity_level, skip_first, on_cuda)