code: def test_recurrence_to_lag_sparse(pad, axis, rec, fmt):
      rec_dense = rec.toarray()
  
      rec = rec.asformat(fmt)
  
      lag_sparse = librosa.segment.recurrence_to_lag(
          rec, pad=pad, axis=axis
      )
      lag_dense = librosa.segment.recurrence_to_lag(
          rec_dense, pad=pad, axis=axis
      )
  
      assert scipy.sparse.issparse(lag_sparse)
      assert rec.format == lag_sparse.format
      assert rec.dtype == lag_sparse.dtype
      assert np.allclose(lag_sparse.toarray(), lag_dense)
  
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 27 for calling a global function with example usage: test_recurrence_to_lag_sparse(pad, axis, rec, fmt) without return types