code: def spatial_select_columnar(xvals, yvals, geometry):
      if "cudf" in sys.modules:
          import cudf
  
          if isinstance(xvals, cudf.Series):
              xvals = xvals.values.astype("float")
              yvals = yvals.values.astype("float")
              try:
                  import cuspatial
  
                  result = cuspatial.point_in_polygon(
                      xvals,
                      yvals,
                      cudf.Series([0], index=["selection"]),
                      [0],
                      geometry[:, 0],
                      geometry[:, 1],
                  )
                  return result.values
              except ImportError:
                  xvals = np.asarray(xvals)
                  yvals = np.asarray(yvals)
      if "dask" in sys.modules:
          import dask.dataframe as dd
  
          if isinstance(xvals, dd.Series):
              try:
                  xvals.name = "xvals"
                  yvals.name = "yvals"
                  df = xvals.to_frame().join(yvals)
                  return df.map_partitions(
                      lambda df, geometry: spatial_select_columnar(
                          df.xvals, df.yvals, geometry
                      ),
                      geometry,
                      meta=pd.Series(dtype=bool),
                  )
              except Exception:
                  xvals = np.asarray(xvals)
                  yvals = np.asarray(yvals)
      x0, x1 = geometry[:, 0].min(), geometry[:, 0].max()
      y0, y1 = geometry[:, 1].min(), geometry[:, 1].max()
      sel_mask = (
          (xvals >= x0) & (xvals <= x1) & (yvals >= y0) & (yvals <= y1)
      )
      masked_xvals = xvals[sel_mask]
      masked_yvals = yvals[sel_mask]
      try:
          from spatialpandas.geometry import PointArray, Polygon
  
          points = PointArray(
              (
                  masked_xvals.astype("float"),
                  masked_yvals.astype("float"),
              )
          )
          poly = Polygon(
              [np.concatenate([geometry, geometry[:1]]).flatten()]
          )
          geom_mask = points.intersects(poly)
      except ImportError:
          try:
              from shapely.geometry import Point, Polygon
  
              points = (
                  Point(x, y)
                  for x, y in zip(masked_xvals, masked_yvals)
              )
              poly = Polygon(geometry)
              geom_mask = np.array([poly.contains(p) for p in points])
          except ImportError:
              raise ImportError(
                  "Lasso selection on tabular data requires "
                  "either spatialpandas or shapely to be available."
              ) from None
      if isinstance(xvals, pd.Series):
          sel_mask[sel_mask.index[np.where(sel_mask)[0]]] = geom_mask
      else:
          sel_mask[np.where(sel_mask)[0]] = geom_mask
      return sel_mask
  
imports: import sys
  import numpy
  import pandas
  from ..core import Dataset, NdOverlay, util
  from ..streams import Lasso, Selection1D, SelectionXY
  from ..util.transform import dim
  from .annotation import HSpan, VSpan
label_desc: Use image node_id 2 for calling a global function with example usage: spatial_select_columnar(xvals, yvals, geometry) and returns: sel_mask, result, df