code: def canonical_name(k: str, config: dict) -> str:
      """Return the canonical name for a key.
  
      Handles user choice of '-' or '_' conventions by standardizing on whichever
      version was set first. If a key already exists in either hyphen or
      underscore form, the existing version is the canonical name. If neither
      version exists the original key is used as is.
      """
      try:
          if k in config:
              return k
      except TypeError:
          # config is not a mapping, return the same name as provided
          return k
  
      altk = k.replace("_", "-") if "_" in k else k.replace("-", "_")
  
      if altk in config:
          return altk
  
      return k
  
imports: from __future__ import annotations
  import ast
  import base64
  import builtins
  import json
  import os
  import site
  import sys
  import threading
  import warnings
  from collections.abc import Mapping, Sequence
  from typing import Any, Literal
  import yaml
  from dask.typing import no_default
label_desc: Use image node_id 2 for calling a global function with example usage: canonical_name(k, config) and returns: k, altk, k, k