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","(",")",")"]
docstr: Finish all asynchronous GPU computations to get correct timings.
docstr_tok: ["Finish","all","asynchronous","GPU","computations","to","get","correct","timings","."]
code: def _cuda_sync(self):
      """
      Finish all asynchronous GPU computations to get correct timings.
      """
      if self.cuda_available:
          torch.cuda.synchronize()
  
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 4 for calling the Timer obj's underlying member method code with example usage: obj._cuda_sync() without return types