def adaptive_rbf_interpolation(residuals_df, grid_gdf, k=6):
            """
            Perform RBF interpolation with adaptive epsilon and smooth parameters based on local station density.

            Parameters:
            - residuals_df: DataFrame containing 'X', 'Y', and 'Residual_Normalized'.
            - grid_gdf: GeoDataFrame containing grid points with 'X' and 'Y'.
            - k: Number of nearest neighbors to consider for adaptive parameter tuning.

            Returns:
            - z: Interpolated residuals for grid points.
            """
            # Build KDTree for efficient neighbor search
            tree = cKDTree(residuals_df[['X', 'Y']].values)
            
            # Query k nearest neighbors for each grid point
            distances, _ = tree.query(grid_gdf[['X', 'Y']].values, k=k, n_jobs=-1)
            
            # Calculate adaptive epsilon as the average distance to k neighbors
            adaptive_epsilon = distances.mean(axis=1)
            
            # Calculate local spatial variability (standard deviation) within k neighbors
            residuals = residuals_df['Residual_Normalized'].values
            grid_residuals = residuals_df.iloc[_].groupby(level=0).agg({'Residual_Normalized': 'std'}).values.flatten()
            adaptive_smooth = np.clip(grid_residuals, 0.05, 0.2)  # Ensure smooth is within a reasonable range
            
            # Perform RBF interpolation for each grid point with adaptive parameters
            interpolated_residuals = []
            for i, (x, y) in enumerate(zip(grid_gdf['X'], grid_gdf['Y'])):
                # Select points within a certain radius based on adaptive_epsilon
                idx = tree.query_ball_point([x, y], r=adaptive_epsilon[i]*2)
                if len(idx) < k:
                    # Fallback to global parameters if insufficient neighbors
                    epsilon = np.mean([
                        np.diff(np.sort(residuals_df['X'].unique())).mean(),
                        np.diff(np.sort(residuals_df['Y'].unique())).mean()
                    ])
                    smooth = 0.1
                else:
                    epsilon = adaptive_epsilon[i]
                    smooth = adaptive_smooth[i]
                
                # Create RBF interpolator with adaptive parameters
                rbf = Rbf(
                    residuals_df.iloc[idx]['X'],
                    residuals_df.iloc[idx]['Y'],
                    residuals_df.iloc[idx]['Residual_Normalized'],
                    function='multiquadric',
                    smooth=smooth,
                    epsilon=epsilon
                )
                
                # Interpolate residual at grid point
                z_i = rbf(x, y)
                interpolated_residuals.append(z_i)
            
            # Convert to numpy array
            z = np.array(interpolated_residuals)
            
            return z

Traceback (most recent call last):
  File "c:\Users\Lenovo\Downloads\pythonStationsData\xgboost_interpolation_rbf.py", line 2570, in <module>
    smoothed_temperature, transform = plot_stations_with_boundary_and_interpolation(
  File "c:\Users\Lenovo\Downloads\pythonStationsData\xgboost_interpolation_rbf.py", line 1440, in plot_stations_with_boundary_and_interpolation
    z_normalized = adaptive_rbf_interpolation(residuals_df, grid_gdf)
  File "c:\Users\Lenovo\Downloads\pythonStationsData\xgboost_interpolation_rbf.py", line 1387, in adaptive_rbf_interpolation
    distances, _ = tree.query(grid_gdf[['X', 'Y']].values, k=k, n_jobs=-1)
  File "_ckdtree.pyx", line 786, in scipy.spatial._ckdtree.cKDTree.query
  File "_ckdtree.pyx", line 390, in scipy.spatial._ckdtree.get_num_workers
TypeError: Unexpected keyword argument {'n_jobs': -1}