code: def logger(log_dir, need_time=True, need_stdout=False):
      log = logging.getLogger(__name__)
      log.setLevel(logging.DEBUG)
      fh = logging.FileHandler(log_dir)
      fh.setLevel(logging.DEBUG)
      formatter = logging.Formatter(
          fmt="%(asctime)s %(message)s", datefmt="%m/%d/%Y-%I:%M:%S"
      )
      if need_stdout:
          ch = logging.StreamHandler(sys.stdout)
          ch.setLevel(logging.DEBUG)
          log.addHandler(ch)
      if need_time:
          fh.setFormatter(formatter)
          if need_stdout:
              ch.setFormatter(formatter)
      log.addHandler(fh)
      return log
  
imports: import math
  import os
  import random
  import sys
  import time
  import warnings
  import numpy
  import numpy
  import shutil
  import logging
  import torch
  import torchvision.transforms
  import torchvision.datasets
  import torch.nn
label_desc: Use image node_id 19 for calling a global function with example usage: logger(log_dir, need_time, need_stdout) and returns: log