def act(self, states, internals, deterministic=False, independent=False, fetch_tensors=None, index=<NUM_LIT:0>):
name = next(iter(states))<EOL>state = np.asarray(states[name])<EOL>batched = (state.ndim != len(self.states_spec[name]['<STR_LIT>']))<EOL>if batched:<EOL><INDENT>assert state.shape[<NUM_LIT:0>] <= self.batching_capacity<EOL><DEDENT>fetches = [self.actions_output, self.internals_output, self.timestep_output]<EOL>if self.network is not None and fetch_tensors is not None:<EOL><INDENT>for name in fetch_tensors:<EOL><INDENT>valid, tensor = self.network.get_named_tensor(name)<EOL>if valid:<EOL><INDENT>fetches.append(tensor)<EOL><DEDENT>else:<EOL><INDENT>keys = self.network.get_list_of_named_tensor()<EOL>raise TensorForceError('<STR_LIT>'.format(name, keys))<EOL><DEDENT><DEDENT><DEDENT>feed_dict = self.get_feed_dict(<EOL>states=states,<EOL>internals=internals,<EOL>deterministic=deterministic,<EOL>independent=independent,<EOL>index=index<EOL>)<EOL>fetch_list = self.monitored_session.run(fetches=fetches, feed_dict=feed_dict)<EOL>actions, internals, timestep = fetch_list[<NUM_LIT:0>:<NUM_LIT:3>]<EOL>if not batched:<EOL><INDENT>actions = {name: actions[name][<NUM_LIT:0>] for name in sorted(actions)}<EOL>internals = {name: internals[name][<NUM_LIT:0>] for name in sorted(internals)}<EOL><DEDENT>if self.network is not None and fetch_tensors is not None:<EOL><INDENT>fetch_dict = dict()<EOL>for index_, tensor in enumerate(fetch_list[<NUM_LIT:3>:]):<EOL><INDENT>name = fetch_tensors[index_]<EOL>fetch_dict[name] = tensor<EOL><DEDENT>return actions, internals, timestep, fetch_dict<EOL><DEDENT>else:<EOL><INDENT>return actions, internals, timestep<EOL><DEDENT>
Does a forward pass through the model to retrieve action (outputs) given inputs for state (and internal
state, if applicable (e.g. RNNs))

Args:
    states (dict): Dict of state values (each key represents one state space component).
    internals (dict): Dict of internal state values (each key represents one internal state component).
    deterministic (bool): If True, will not apply exploration after actions are calculated.
    independent (bool): If true, action is not followed by observe (and hence not included
        in updates).
    fetch_tensors (list): List of names of additional tensors (from the model's network) to fetch (and return).
    index: (int) index of the episode we want to produce the next action

Returns:
    tuple:
        - Actual action-outputs (batched if state input is a batch).
        - Actual values of internal states (if applicable) (batched if state input is a batch).
        - The timestep (int) after calculating the (batch of) action(s).