class_docstr: Tests context.
      
class_docstr_tok: ["Tests","context","."]
docstr: Tests the mode context manager.
          
docstr_tok: ["Tests","the","mode","context","manager","."]
code: def test_global_mode(self):
      """Tests the mode context manager."""
      global_mode = context.global_mode()
      self.assertIsInstance(global_mode, tf.Tensor)
  
      mode_train = context.global_mode_train()
      mode_eval = context.global_mode_eval()
      mode_predict = context.global_mode_predict()
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
  
          global_mode_ = sess.run(global_mode)
          self.assertEqual(
              tf.compat.as_str(global_mode_),
              tf.estimator.ModeKeys.TRAIN,
          )
  
          (
              global_mode_,
              mode_train_,
              mode_eval_,
              mode_predict_,
          ) = sess.run(
              [global_mode, mode_train, mode_eval, mode_predict],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.TRAIN
              },
          )
          self.assertEqual(global_mode_, tf.estimator.ModeKeys.TRAIN)
          self.assertTrue(mode_train_)
          self.assertFalse(mode_eval_)
          self.assertFalse(mode_predict_)
  
          (
              global_mode_,
              mode_train_,
              mode_eval_,
              mode_predict_,
          ) = sess.run(
              [global_mode, mode_train, mode_eval, mode_predict],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.EVAL
              },
          )
          self.assertEqual(global_mode_, tf.estimator.ModeKeys.EVAL)
          self.assertFalse(mode_train_)
          self.assertTrue(mode_eval_)
          self.assertFalse(mode_predict_)
  
          (
              global_mode_,
              mode_train_,
              mode_eval_,
              mode_predict_,
          ) = sess.run(
              [global_mode, mode_train, mode_eval, mode_predict],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.PREDICT
              },
          )
          self.assertEqual(global_mode_, tf.estimator.ModeKeys.PREDICT)
          self.assertFalse(mode_train_)
          self.assertFalse(mode_eval_)
          self.assertTrue(mode_predict_)
  
      global_mode_values = tf.get_collection_ref(
          context._GLOBAL_MODE_KEY
      )
      self.assertEqual(len(global_mode_values), 1)
  
imports: import tensorflow
  from texar.tf import context
label_desc: Use image node_id 1 for calling the ContextTest obj's underlying member method code with example usage: obj.test_global_mode() without return types