code: def assert_same_distances_for_common_neighbors(
      query_idx,
      dist_row_a,
      dist_row_b,
      indices_row_a,
      indices_row_b,
      rtol,
      atol,
  ):
      """Check that the distances of common neighbors are equal up to tolerance.
  
      This does not check if there are missing neighbors in either result set.
      Missingness is handled by assert_no_missing_neighbors.
      """
      # Compute a mapping from indices to distances for each result set and
      # check that the computed neighbors with matching indices are within
      # the expected distance tolerance.
      indices_to_dist_a = dict(zip(indices_row_a, dist_row_a))
      indices_to_dist_b = dict(zip(indices_row_b, dist_row_b))
  
      common_indices = set(indices_row_a).intersection(
          set(indices_row_b)
      )
      for idx in common_indices:
          dist_a = indices_to_dist_a[idx]
          dist_b = indices_to_dist_b[idx]
          try:
              assert_allclose(dist_a, dist_b, rtol=rtol, atol=atol)
          except AssertionError as e:
              # Wrap exception to provide more context while also including
              # the original exception with the computed absolute and
              # relative differences.
              raise AssertionError(
                  f"Query vector with index {query_idx} lead to different distances"
                  f" for common neighbor with index {idx}:"
                  f" dist_a={dist_a} vs dist_b={dist_b} (with atol={atol} and"
                  f" rtol={rtol})"
              ) from e
  
imports: import itertools
  import re
  import warnings
  from functools import partial
  import numpy
  import pytest
  import threadpoolctl
  from scipy.spatial.distance import cdist
  from sklearn.metrics import euclidean_distances, pairwise_distances
  from sklearn.metrics._pairwise_distances_reduction import ArgKmin, ArgKminClassMode, BaseDistancesReductionDispatcher, RadiusNeighbors, RadiusNeighborsClassMode, sqeuclidean_row_norms
  from sklearn.utils._testing import assert_allclose, assert_array_equal, create_memmap_backed_data
  from sklearn.utils.fixes import CSR_CONTAINERS
label_desc: Use image node_id 2 for calling a global function with example usage: assert_same_distances_for_common_neighbors(query_idx, dist_row_a, dist_row_b, indices_row_a, indices_row_b, rtol, atol) without return types