code: def make_policy_from_output_dir(
      path: Union[Path, str]
  ) -> SerializedTorchPolicy:
      """Create a serialized Torch policy instance from an output directory of a previous run. The
      directory is expected to contain the hydra config of the run and all associated
      information needed for the policy (like state_dict).
  
      :param path: Path of the output directory to use
      :return: The newly instantiated policy
      """
      with SwitchWorkingDirectoryToInput(path):
          cfg = read_config("hydra_config.yaml")
          policy = SerializedTorchPolicy(
              model=cfg["model"],
              state_dict_file="state_dict.pt",
              spaces_dict_file="spaces_config.pkl",
              device="cpu",
          )
  
      return policy
  
imports: import os
  from pathlib import Path
  from typing import Mapping, Union, Sequence
  import hydra
  import yaml
  from hydra import initialize_config_module, compose
  from hydra.core.hydra_config import HydraConfig
  from omegaconf import DictConfig
  from maze.core.agent.serialized_torch_policy import SerializedTorchPolicy
  from maze.core.env.maze_env import MazeEnv
  from maze.core.utils.factory import Factory, ConfigType, CollectionOfConfigType
  from maze.core.wrappers.wrapper_factory import WrapperFactory
label_desc: Use image node_id 8 for calling a global function with example usage: make_policy_from_output_dir(path) and returns: policy