code: def __harmonic_distance(logs, a, b):
      """Compute the harmonic distance between ratios a and b.
  
      Harmonic distance is defined as `log2(a * b) - 2*log2(gcd(a, b))` [#]_.
  
      Here we are expressing a and b as prime factorization exponents,
      and the prime basis are provided in their log2 form.
  
      .. [#] Tenney, James.
          "On ‘Crystal Growth’ in harmonic space (1993–1998)."
          Contemporary Music Review 27.1 (2008): 47-56.
      """
      a = np.array(a)
      b = np.array(b)
  
      # numerator = positive exponents
      a_num = np.maximum(a, 0)
      # denominator = negative exponents
      a_den = a_num - a
  
      b_num = np.maximum(b, 0)
      b_den = b_num - b
  
      # log2(ab / gcd(a,b)**2) = log(a) + log(b) - 2 * log(gcd(a,b))
      # gcd(a,b) for rationals: gcd(a_num, b_num) / lcm(a_den, b_den)
      # gcd = minimum(a_num, b_num) and lcm = maximum(a_den, b_den)
      gcd = np.minimum(a_num, b_num) - np.maximum(a_den, b_den)
  
      # Rounding this to 6 decimals to avoid floating point weirdness
      return np.around(logs.dot(a + b - 2 * gcd), 6)
  
file_path: librosa/librosa/core/intervals.py
imports: from importlib import resources
  from typing import Collection, Dict, List, Union, overload, Iterable
  from typing_extensions import Literal
  import msgpack
  import numpy
  from numpy.typing import ArrayLike
  from .._cache import cache
  from .._typing import _FloatLike_co
label_desc: Use image node_id 6 for calling a global function with example usage: __harmonic_distance(logs, a, b) and returns: np