def create_observe_operations(self, terminal, reward, index):
<EOL>num_episodes = tf.count_nonzero(input_tensor=terminal, dtype=util.tf_dtype('<STR_LIT:int>'))<EOL>increment_episode = tf.assign_add(ref=self.episode, value=tf.to_int64(x=num_episodes))<EOL>increment_global_episode = tf.assign_add(ref=self.global_episode, value=tf.to_int64(x=num_episodes))<EOL>with tf.control_dependencies(control_inputs=(increment_episode, increment_global_episode)):<EOL><INDENT>fn = (lambda x: tf.stop_gradient(input=x[:self.list_buffer_index[index]]))<EOL>states = util.map_tensors(fn=fn, tensors=self.list_states_buffer, index=index)<EOL>internals = util.map_tensors(fn=fn, tensors=self.list_internals_buffer, index=index)<EOL>actions = util.map_tensors(fn=fn, tensors=self.list_actions_buffer, index=index)<EOL>terminal = tf.stop_gradient(input=terminal)<EOL>reward = tf.stop_gradient(input=reward)<EOL>observation = self.fn_observe_timestep(<EOL>states=states,<EOL>internals=internals,<EOL>actions=actions,<EOL>terminal=terminal,<EOL>reward=reward<EOL>)<EOL><DEDENT>with tf.control_dependencies(control_inputs=(observation,)):<EOL><INDENT>reset_index = tf.assign(ref=self.list_buffer_index[index], value=<NUM_LIT:0>)<EOL><DEDENT>with tf.control_dependencies(control_inputs=(reset_index,)):<EOL><INDENT>self.episode_output = self.global_episode + <NUM_LIT:0><EOL><DEDENT>self.list_buffer_index_reset_op = tf.group(<EOL>*(tf.assign(ref=self.list_buffer_index[n], value=<NUM_LIT:0>) for n in range(self.num_parallel))<EOL>)<EOL>
Returns the tf op to fetch when an observation batch is passed in (e.g. an episode's rewards and
terminals). Uses the filled tf buffers for states, actions and internals to run
the tf_observe_timestep (model-dependent), resets buffer index and increases counters (episodes,
timesteps).

Args:
    terminal: The 1D tensor (bool) of terminal signals to process (more than one True within that list is ok).
    reward: The 1D tensor (float) of rewards to process.

Returns: Tf op to fetch when `observe()` is called.