code: def get_stopped_experiment_config(
      exp_id: str, exp_dir: str | Path | None = None
  ) -> ExperimentConfig:
      """Get the experiment config of a stopped experiment.
  
      Parameters
      ----------
      exp_id
          The experiment ID.
      exp_dir
          The experiment working directory which is expected to contain a folder named ``exp_id``.
  
      Returns
      -------
      The config.
      It's the config returned by :func:`get_stopped_experiment_config_json`,
      loaded by :class:`ExperimentConfig`.
      """
      if isinstance(exp_dir, Path):
          exp_dir = str(exp_dir)
      config_json = get_stopped_experiment_config_json(exp_id, exp_dir)  # type: ignore
      if config_json is None:
          raise ValueError(
              f"Config of {exp_id} (under {exp_dir}) failed to be loaded."
          )
      config = ExperimentConfig(**config_json)  # type: ignore
      if exp_dir and not os.path.samefile(
          exp_dir, config.experiment_working_directory
      ):
          msg = "Experiment working directory provided in command line (%s) is different from experiment config (%s)"
          _logger.warning(
              msg, exp_dir, config.experiment_working_directory
          )
          config.experiment_working_directory = exp_dir
      return config
  
imports: from __future__ import annotations
  import contextlib
  from dataclasses import dataclass, fields
  from datetime import datetime
  import logging
  import os.path
  from pathlib import Path
  import socket
  from subprocess import Popen
  import sys
  import time
  from typing import Any, TYPE_CHECKING, cast
  from typing_extensions import Literal
  from .config import ExperimentConfig
  from .None import rest
  from ..tools.nnictl.config_utils import Experiments, Config
  from ..tools.nnictl.nnictl_utils import update_experiment
label_desc: Use image node_id 6 for calling a global function with example usage: get_stopped_experiment_config(exp_id, exp_dir) and returns: config