code: def test_cross_similarity_affinity(metric, bandwidth):
      srand()
      data_ref = np.random.randn(3, 70)
      data = np.random.randn(3, 50)
      distance = cdist(data_ref.T, data.T, metric=metric)
      rec = librosa.segment.cross_similarity(
          data,
          data_ref,
          mode="affinity",
          metric=metric,
          sparse=True,
          bandwidth=bandwidth,
      )
  
      i, j, vals = scipy.sparse.find(rec)
      logvals = np.log(vals)
  
      ratio = -logvals / (distance[i, j] + librosa.util.tiny(distance))
  
      if bandwidth is None:
          assert np.allclose(
              -logvals, distance[i, j] * np.nanmax(ratio)
          )
      else:
          assert np.allclose(-logvals, distance[i, j] * bandwidth)
  
imports: from typing import Union
  import warnings
  import os
  import numpy
  import scipy
  from scipy.spatial.distance import cdist, pdist, squareform
  import pytest
  from test_core import srand
  import librosa
label_desc: Use image node_id 4 for calling a global function with example usage: test_cross_similarity_affinity(metric, bandwidth) without return types