code: def set_logger(file_name=None):
      """
      Writing logs to a file if file_name,
      the handler needs to be closed by `close_logger()` after use.
  
      :param file_name:
      :return:
      """
      # pylint: disable=no-name-in-module
      # This is done so if the user had TF 1.12.1 or a new version the code
      # does not brake. First part of the try is renaming the TF 1.12.1 to
      # fit the TF 1.13.1>= naming scheme, while the second is just a normal
      # import for TF 1.13.1>=
      try:
          # pylint: disable=no-name-in-module
          from tensorflow.python.platform.tf_logging import (
              _get_logger as get_logger,
          )
      except ImportError:
          from tensorflow.python.platform.tf_logging import get_logger
  
      logger = get_logger()
      tf.logging.set_verbosity(tf.logging.INFO)
      logger.handlers = []
  
      # adding console output
      f = log.Formatter(CONSOLE_LOG_FORMAT)
      std_handler = log.StreamHandler(sys.stdout)
      std_handler.setFormatter(f)
      logger.addHandler(std_handler)
  
      if file_name:
          # adding file output
          f = log.Formatter(FILE_LOG_FORMAT)
          file_handler = log.FileHandler(file_name)
          file_handler.setFormatter(f)
          logger.addHandler(file_handler)
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  import errno
  import importlib
  import logging
  import os
  import re
  import sys
  import warnings
  import nibabel
  import numpy
  import pandas
  import scipy.ndimage
  import tensorflow
  from tensorflow.core.framework import summary_pb2
  from niftynet.io.image_loader import load_image_obj
  from niftynet.utilities.niftynet_global_config import NiftyNetGlobalConfig
  from niftynet.utilities.util_import import require_module
label_desc: Use image node_id 28 for calling a global function with example usage: set_logger(file_name) without return types