code: def key_to_degrees(key: str) -> np.ndarray:
      """Construct the diatonic scale degrees for a given key.
  
      Parameters
      ----------
      key : str
          Must be in the form TONIC:key.  Tonic must be upper case (``CDEFGAB``),
          key must be lower-case
          (``maj``, ``min``, ``ionian``, ``dorian``, ``phrygian``, ``lydian``, ``mixolydian``, ``aeolian``, ``locrian``).
  
          The following abbreviations are supported for the modes: either the first three letters of the mode name
          (e.g. "mix") or the mode name without "ian" (e.g. "mixolyd").
  
          Both ``major`` and ``maj`` are supported as abbreviations.
  
          Single and multiple accidentals (``b!♭`` for flat, or ``#♯`` for sharp) are supported.
  
          Examples: ``C:maj, C:major, Dbb:min, A♭:min, D:aeo, E𝄪:phryg``.
  
      Returns
      -------
      degrees : np.ndarray
          An array containing the semitone numbers (0=C, 1=C#, ... 11=B)
          for each of the seven scale degrees in the given key, starting
          from the tonic.
  
      See Also
      --------
      key_to_notes
  
      Examples
      --------
      >>> librosa.key_to_degrees('C:maj')
      array([ 0,  2,  4,  5,  7,  9, 11])
  
      >>> librosa.key_to_degrees('C#:maj')
      array([ 1,  3,  5,  6,  8, 10,  0])
  
      >>> librosa.key_to_degrees('A:min')
      array([ 9, 11,  0,  2,  4,  5,  7])
  
      >>> librosa.key_to_degrees('A:min')
      array([ 9, 11,  0,  2,  4,  5,  7])
  
      """
      notes = dict(
          maj=np.array([0, 2, 4, 5, 7, 9, 11]),
          min=np.array([0, 2, 3, 5, 7, 8, 10]),
      )
  
      match = KEY_RE.match(key)
  
      if not match:
          raise ParameterError(f"Improper key format: {key:s}")
  
      if match.group("mode") or not match.group("scale"):
          equiv = __mode_to_key(key)
          offset = OFFSET_DICT[match.group("mode")[:3]]
          return np.roll(key_to_degrees(equiv), -offset)
  
      pitch_map = {
          "C": 0,
          "D": 2,
          "E": 4,
          "F": 5,
          "G": 7,
          "A": 9,
          "B": 11,
      }
      tonic = match.group("tonic").upper()
      accidental = match.group("accidental")
      counts = Counter(accidental)
      offset = sum([ACC_MAP[acc] * counts[acc] for acc in ACC_MAP])
  
      scale = match.group("scale")[:3].lower()
  
      return (notes[scale] + pitch_map[tonic] + offset) % 12
  
imports: import re
  import numpy
  from numba import jit
  from collections import Counter
  from .intervals import INTERVALS
  from .._cache import cache
  from ..util.exceptions import ParameterError
  from typing import Dict, List, Iterable, Union, overload
  from ..util.decorators import vectorize
  from .._typing import _ScalarOrSequence, _FloatLike_co, _SequenceLike, _IterableLike
label_desc: Use image node_id 16 for calling a global function with example usage: key_to_degrees(key) and returns: unknown, np