code: def _geom_predicate_query(left_df, right_df, predicate, distance):
      """Compute geometric comparisons and get matching indices.
  
      Parameters
      ----------
      left_df : GeoDataFrame
      right_df : GeoDataFrame
      predicate : string
          Binary predicate to query.
  
      Returns
      -------
      DataFrame
          DataFrame with matching indices in
          columns named `_key_left` and `_key_right`.
      """
      with warnings.catch_warnings():
          # We don't need to show our own warning here
          # TODO remove this once the deprecation has been enforced
          warnings.filterwarnings(
              "ignore",
              "Generated spatial index is empty",
              FutureWarning,
          )
  
          original_predicate = predicate
  
          if predicate == "within":
              # within is implemented as the inverse of contains
              # contains is a faster predicate
              # see discussion at https://github.com/geopandas/geopandas/pull/1421
              predicate = "contains"
              sindex = left_df.sindex
              input_geoms = right_df.geometry
          else:
              # all other predicates are symmetric
              # keep them the same
              sindex = right_df.sindex
              input_geoms = left_df.geometry
  
      if sindex:
          l_idx, r_idx = sindex.query(
              input_geoms,
              predicate=predicate,
              sort=False,
              distance=distance,
          )
          indices = pd.DataFrame(
              {"_key_left": l_idx, "_key_right": r_idx}
          )
      else:
          # when sindex is empty / has no valid geometries
          indices = pd.DataFrame(
              columns=["_key_left", "_key_right"], dtype=float
          )
  
      if original_predicate == "within":
          # within is implemented as the inverse of contains
          # flip back the results
          indices = indices.rename(
              columns={
                  "_key_left": "_key_right",
                  "_key_right": "_key_left",
              }
          )
  
      return indices
  
file_path: geopandas/geopandas/tools/sjoin.py
imports: from typing import Optional
  import warnings
  import numpy
  import pandas
  from geopandas import GeoDataFrame
  from geopandas.array import _check_crs, _crs_mismatch_warn
label_desc: Use image node_id 3 for calling a global function with example usage: _geom_predicate_query(left_df, right_df, predicate, distance) and returns: indices