<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inverse_distance_to_points(points, values, xi, r, gamma=None, kappa=None, min_neighbors=3, kind='cressman'):
 r"""Generate an inverse distance weighting interpolation to the given points. Values are assigned to the given interpolation points based on either [Cressman1959]_ or [Barnes1964]_. The Barnes implementation used here based on [Koch1983]_. Parameters points: array_like, shape (n, 2) Coordinates of the data points. values: array_like, shape (n,) Values of the data points. xi: array_like, shape (M, 2) Points to interpolate the data onto. r: float Radius from grid center, within which observations are considered and weighted. gamma: float Adjustable smoothing parameter for the barnes interpolation. Default None. kappa: float Response parameter for barnes interpolation. Default None. min_neighbors: int Minimum number of neighbors needed to perform barnes or cressman interpolation for a point. Default is 3. kind: str Specify what inverse distance weighting interpolation to use. Options: 'cressman' or 'barnes'. Default 'cressman' Returns ------- img: (M,) ndarray Array representing the interpolated values for each input point in `xi` See Also -------- inverse_distance_to_grid """

    obs_tree = cKDTree(points)

    indices = obs_tree.query_ball_point(xi, r=r)

    img = np.empty(shape=(xi.shape[0]), dtype=values.dtype)
    img.fill(np.nan)

    for idx, (matches, grid) in enumerate(zip(indices, xi)):
        if len(matches) >= min_neighbors:

            x1, y1 = obs_tree.data[matches].T
            values_subset = values[matches]
            dists = geometry.dist_2(grid[0], grid[1], x1, y1)

            if kind == 'cressman':
                img[idx] = cressman_point(dists, values_subset, r)
            elif kind == 'barnes':
                img[idx] = barnes_point(dists, values_subset, kappa, gamma)

            else:
                raise ValueError(str(kind) + ' interpolation not supported.')

    return img