def create_act_operations(self, states, internals, deterministic, independent, index):
<EOL>operations = list()<EOL>if self.variable_noise is not None and self.variable_noise > <NUM_LIT:0.0>:<EOL><INDENT>self.fn_actions_and_internals(<EOL>states=states,<EOL>internals=internals,<EOL>deterministic=deterministic<EOL>)<EOL>noise_deltas = list()<EOL>for variable in self.get_variables():<EOL><INDENT>noise_delta = tf.random_normal(shape=util.shape(variable), mean=<NUM_LIT:0.0>, stddev=self.variable_noise)<EOL>noise_deltas.append(noise_delta)<EOL>operations.append(variable.assign_add(delta=noise_delta))<EOL><DEDENT><DEDENT>with tf.control_dependencies(control_inputs=operations):<EOL><INDENT>self.actions_output, self.internals_output = self.fn_actions_and_internals(<EOL>states=states,<EOL>internals=internals,<EOL>deterministic=deterministic<EOL>)<EOL><DEDENT>with tf.control_dependencies(control_inputs=[self.actions_output[name] for name in sorted(self.actions_output)]):<EOL><INDENT>operations = list()<EOL>if self.variable_noise is not None and self.variable_noise > <NUM_LIT:0.0>:<EOL><INDENT>for variable, noise_delta in zip(self.get_variables(), noise_deltas):<EOL><INDENT>operations.append(variable.assign_sub(delta=noise_delta))<EOL><DEDENT><DEDENT><DEDENT>with tf.control_dependencies(control_inputs=operations):<EOL><INDENT>for name in sorted(self.actions_exploration):<EOL><INDENT>self.actions_output[name] = tf.cond(<EOL>pred=self.deterministic_input,<EOL>true_fn=(lambda: self.actions_output[name]),<EOL>false_fn=(lambda: self.fn_action_exploration(<EOL>action=self.actions_output[name],<EOL>exploration=self.actions_exploration[name],<EOL>action_spec=self.actions_spec[name]<EOL>))<EOL>)<EOL><DEDENT><DEDENT>def independent_act():<EOL><INDENT>"""<STR_LIT>"""<EOL>return self.global_timestep<EOL><DEDENT>def normal_act():<EOL><INDENT>"""<STR_LIT>"""<EOL>operations = list()<EOL>batch_size = tf.shape(input=states[next(iter(sorted(states)))])[<NUM_LIT:0>]<EOL>for name in sorted(states):<EOL><INDENT>operations.append(tf.assign(<EOL>ref=self.list_states_buffer[name][index, self.list_buffer_index[index]: self.list_buffer_index[index] + batch_size],<EOL>value=states[name]<EOL>))<EOL><DEDENT>for name in sorted(internals):<EOL><INDENT>operations.append(tf.assign(<EOL>ref=self.list_internals_buffer[name][index, self.list_buffer_index[index]: self.list_buffer_index[index] + batch_size],<EOL>value=internals[name]<EOL>))<EOL><DEDENT>for name in sorted(self.actions_output):<EOL><INDENT>operations.append(tf.assign(<EOL>ref=self.list_actions_buffer[name][index, self.list_buffer_index[index]: self.list_buffer_index[index] + batch_size],<EOL>value=self.actions_output[name]<EOL>))<EOL><DEDENT>with tf.control_dependencies(control_inputs=operations):<EOL><INDENT>operations = list()<EOL>operations.append(tf.assign(<EOL>ref=self.list_buffer_index[index: index+<NUM_LIT:1>],<EOL>value=tf.add(self.list_buffer_index[index: index+<NUM_LIT:1>], tf.constant([<NUM_LIT:1>]))<EOL>))<EOL>operations.append(tf.assign_add(<EOL>ref=self.timestep,<EOL>value=tf.to_int64(x=batch_size)<EOL>))<EOL>operations.append(tf.assign_add(<EOL>ref=self.global_timestep,<EOL>value=tf.to_int64(x=batch_size)<EOL>))<EOL><DEDENT>with tf.control_dependencies(control_inputs=operations):<EOL><INDENT>return self.global_timestep + <NUM_LIT:0><EOL><DEDENT><DEDENT>self.timestep_output = tf.cond(<EOL>pred=independent,<EOL>true_fn=independent_act,<EOL>false_fn=normal_act<EOL>)<EOL>
Creates and stores tf operations that are fetched when calling act(): actions_output, internals_output and
timestep_output.

Args:
    states (dict): Dict of state tensors (each key represents one state space component).
    internals (dict): Dict of prior internal state tensors (each key represents one internal state component).
    deterministic: 0D (bool) tensor (whether to not use action exploration).
    independent (bool): 0D (bool) tensor (whether to store states/internals/action in local buffer).