def create_env_index(replay_buffer):
  """Creates the mapping from env_name to their index in the replay buffer."""
  env_index = {}
  buffer_items = sorted(
      replay_buffer.traj_buffer.iteritems(), key=lambda k: k[0])
  for idx, (env_name, _) in enumerate(buffer_items):
    env_index[env_name] = idx
  return env_index