code: def test_training_flag():
      obs_size = (3, 4)
  
      obs0 = np.random.random(obs_size)
      terminal0 = False
  
      obs1 = np.random.random(obs_size)
      terminal1 = True
  
      obs2 = np.random.random(obs_size)
      terminal2 = False
  
      for training in (True, False):
          memory = SequentialMemory(3, window_length=2)
  
          state = np.array(memory.get_recent_state(obs0))
          assert state.shape == (2,) + obs_size
          assert np.allclose(state[0], 0.0)
          assert np.all(state[1] == obs0)
          assert memory.nb_entries == 0
  
          memory.append(obs0, 0, 0.0, terminal1, training=training)
          state = np.array(memory.get_recent_state(obs1))
          assert state.shape == (2,) + obs_size
          assert np.all(state[0] == obs0)
          assert np.all(state[1] == obs1)
          if training:
              assert memory.nb_entries == 1
          else:
              assert memory.nb_entries == 0
  
          memory.append(obs1, 0, 0.0, terminal2, training=training)
          state = np.array(memory.get_recent_state(obs2))
          assert state.shape == (2,) + obs_size
          assert np.allclose(state[0], 0.0)
          assert np.all(state[1] == obs2)
          if training:
              assert memory.nb_entries == 2
          else:
              assert memory.nb_entries == 0
  
file_path: keras-rl/tests/rl/test_memory.py
imports: from __future__ import division
  import pytest
  import numpy
  from numpy.testing import assert_allclose
  from rl.memory import SequentialMemory, RingBuffer
label_desc: Use image node_id 3 for calling a global function with example usage: test_training_flag() without return types