code: def _hilbert_distance(geoms, total_bounds=None, level=16):
      """
      Calculate the distance along a Hilbert curve.
  
      The distances are calculated for the midpoints of the geometries in the
      GeoDataFrame.
  
      Parameters
      ----------
      geoms : GeometryArray
      total_bounds : 4-element array
          Total bounds of geometries - array
      level : int (1 - 16), default 16
          Determines the precision of the curve (points on the curve will
          have coordinates in the range [0, 2^level - 1]).
  
      Returns
      -------
      np.ndarray
          Array containing distances along the Hilbert curve
  
      """
      if geoms.is_empty.any() | geoms.isna().any():
          raise ValueError(
              "Hilbert distance cannot be computed on a GeoSeries with empty or "
              "missing geometries.",
          )
      # Calculate bounds as numpy array
      bounds = geoms.bounds
  
      # Calculate discrete coords based on total bounds and bounds
      x, y = _continuous_to_discrete_coords(bounds, level, total_bounds)
      # Compute distance along hilbert curve
      distances = _encode(level, x, y)
  
      return distances
  
imports: import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _hilbert_distance(geoms, total_bounds, level) and returns: distances