code: def test_update_with_changed_data(update_data, case, metric):
      def evaluate(nn_descent, xs_to_fit, xs_to_query):
          true_nn = NearestNeighbors(metric=metric, n_neighbors=k).fit(
              xs_to_fit
          )
          neighbors, _ = nn_descent.query(xs_to_query, k=k)
          neighbors_expected = true_nn.kneighbors(
              xs_to_query, k, return_distance=False
          )
          p_correct = evaluate_predictions(
              neighbors_expected, neighbors, k
          )
          assert p_correct >= 0.95, (
              "NN-descent query did not get 95% "
              "accuracy on nearest neighbors"
          )
  
      k = 10
      xs_orig, xs_fresh, xs_updated, indices_updated = update_data[case]
      queries1 = xs_orig
  
      # original
      index = NNDescent(
          xs_orig, metric=metric, n_neighbors=40, random_state=1234
      )
      index.prepare()
      evaluate(index, xs_orig, queries1)
      # updated
      index.update(
          xs_fresh=xs_fresh,
          xs_updated=xs_updated,
          updated_indices=indices_updated,
      )
      if xs_fresh is not None:
          xs = np.vstack((xs_orig, xs_fresh))
          queries2 = np.vstack((queries1, xs_fresh))
      else:
          xs = xs_orig
          queries2 = queries1
      if indices_updated is not None:
          xs[indices_updated] = xs_updated
      evaluate(index, xs, queries2)
      if indices_updated is not None:
          evaluate(index, xs, xs_updated)
  
imports: import os
  import io
  import re
  import pytest
  from contextlib import redirect_stdout
  import numpy
  from sklearn.neighbors import KDTree
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import normalize
  import pickle
  import joblib
  import scipy
  from pynndescent import NNDescent, PyNNDescentTransformer
label_desc: Use image node_id 27 for calling a global function with example usage: test_update_with_changed_data(update_data, case, metric) without return types