code: def is_train_mode_py(mode, default=True):
      """Returns a python boolean indicating whether the mode is TRAIN.
  
      Args:
          mode: A string taking value in
              :tf_main:`tf.estimator.ModeKeys <estimator/ModeKeys>`.
              Can be `None`.
          default (bool): The return value when :attr:`mode` is `None`. Default
              is `True`.
  
      Returns:
          A python boolean.
      """
      if mode is None:
          return default
      if mode not in context.valid_modes():
          raise ValueError("Unknown mode: {}".format(mode))
      return mode == tf.estimator.ModeKeys.TRAIN
  
file_path: texar/texar/tf/utils/mode.py
imports: import tensorflow
  from texar.tf import context
label_desc: Use image node_id 5 for calling a global function with example usage: is_train_mode_py(mode, default) and returns: unknown, default