class_docstr: A Worker object is created for each training thread.
class_docstr_tok: ["A","Worker","object","is","created","for","each","training","thread","."]
docstr: Generate a rollout.
docstr_tok: ["Generate","a","rollout","."]
code: def create_rollout(self):
      """Generate a rollout."""
      states = []
      action_prob = []
      actions = []
      rewards = []
      values = []
  
      # Generate the rollout.
  
      for i in range(self.ppo.max_rollout_length):
          if self.env.terminated:
              break
          state = self.env.state
          states.append(state)
          results = self._compute_model(
              self._create_model_inputs(state, self.rnn_states)
          )
          results = [r.numpy() for r in results]
          value = results[self.ppo._value_index]
          probabilities = np.squeeze(
              results[self.ppo._action_prob_index]
          )
          self.rnn_states = [
              np.squeeze(results[i], 0)
              for i in self.ppo._rnn_final_state_indices
          ]
          action = self.ppo._select_action_from_outputs(results, False)
          actions.append(action)
          action_prob.append(probabilities[action])
          values.append(float(value))
          rewards.append(self.env.step(action))
  
      # Compute an estimate of the reward for the rest of the episode.
  
      if not self.env.terminated:
          results = self._compute_model(
              self._create_model_inputs(self.env.state, self.rnn_states)
          )
          final_value = (
              self.ppo.discount_factor
              * results[self.ppo._value_index].numpy()[0]
          )
      else:
          final_value = 0.0
      values.append(final_value)
      if self.env.terminated:
          self.env.reset()
          self.rnn_states = self.ppo._policy.rnn_initial_states
      return (
          states,
          np.array(actions, dtype=np.int32),
          np.array(action_prob, dtype=np.float32),
          np.array(rewards, dtype=np.float32),
          np.array(values, dtype=np.float32),
      )
  
imports: import copy
  import time
  from collections.abc import Sequence
  from multiprocessing.dummy import Pool
  import numpy
  import tensorflow
  from deepchem.models import KerasModel
  from deepchem.models.optimizers import Adam
label_desc: Use image node_id 3 for calling the _Worker obj's underlying member method code with example usage: obj.create_rollout() and returns: states,  np,  np,  np,  np