code: def install_kernel_spec(
      source_dir: str,
      kernel_name: str | None = None,
      user: bool = False,
      replace: bool | None = False,
      prefix: str | None = None,
  ) -> str:
      """Install a kernel spec in a given directory."""
      return KernelSpecManager().install_kernel_spec(
          source_dir, kernel_name, user, replace, prefix
      )
  
imports: from __future__ import annotations
  import json
  import os
  import re
  import shutil
  import typing
  import warnings
  from jupyter_core.paths import SYSTEM_JUPYTER_PATH, jupyter_data_dir, jupyter_path
  from traitlets import Bool, CaselessStrEnum, Dict, HasTraits, List, Set, Type, Unicode, observe
  from traitlets.config import LoggingConfigurable
  from .provisioning import KernelProvisionerFactory
label_desc: Use image node_id 6 for calling a global function with example usage: install_kernel_spec(source_dir, kernel_name, user, replace, prefix) and returns: KernelSpecManager