def create_traj(env, path):
  """Creates a trajectory given an evironment and a trajectory."""
  rewards = []
  index = 0
  done = False
  env.reset()
  while (not done) and index < len(path):
    ac = path[index]
    index += 1
    reward, done = env.step(ac)  # Down
    rewards.append(reward)
  if not done:
    raise RuntimeError('Done must be true since we reach the goal')
  traj = dict(env_name=env.name, rewards=rewards, actions=path)
  return traj