code: def print_and_log(logger, msg):
      # print and log a message (if a logger is present)
      print(msg)
      sys.stdout.flush()
      if logger is not None:
          logger.write("{}\n".format(msg))
          logger.flush()
  
file_path: pyro/pyro/contrib/examples/util.py
imports: import os
  import sys
  import torchvision.datasets
  from torch.utils.data import DataLoader
  from torchvision import transforms
label_desc: Use image node_id 2 for calling a global function with example usage: print_and_log(logger, msg) without return types