code: def evaluate_world_model(
      agent_type, loop_hparams, planner_hparams, model_dir, policy_dir,
      random_starts_step_limit, debug_video_path, log_every_steps
  ):
    
    if debug_video_path:
      debug_video_path = os.path.join(debug_video_path, "0.avi")
  
    storage_env = rl_utils.setup_env(loop_hparams, batch_size=1, max_num_noops=0)
    stacked_env = rl_utils.BatchStackWrapper(
        storage_env, loop_hparams.frame_stack_size
    )
    policy_hparams = trainer_lib.create_hparams(loop_hparams.base_algo_params)
    agent = make_agent_from_hparams(
        agent_type, storage_env, stacked_env, loop_hparams, policy_hparams,
        planner_hparams, model_dir, policy_dir,
        # TODO(koz4k): Loop over eval_sampling_temps?
        sampling_temp=loop_hparams.eval_sampling_temps[0],
    )
    collect_frames_for_random_starts(
        storage_env, stacked_env, agent, loop_hparams.frame_stack_size,
        random_starts_step_limit, log_every_steps
    )
    return rl_utils.evaluate_world_model(
        storage_env, loop_hparams, model_dir, debug_video_path, split=None
    )
docs: Evaluates the world model.