code: def build_and_query(
      doc,
      query,
      topk,
      column_number,
      row_number,
      threads=1,
      dimension=None,
      measure_name=None,
      index_builder=None,
      builder_params=None,
      index_converter=None,
      index_converter_params=None,
      index_searcher=None,
      searcher_params=None,
      index_reformer=None,
      index_reformer_params=None,
  ):
      if measure_name is None:
          measure_name = "SquaredEuclidean"
      if dimension is None:
          dimension = doc.shape[1]
      if index_builder is None:
          index_builder = "SsgBuilder"
      if builder_params is None:
          builder_params = {}
      if index_converter_params is None:
          index_converter_params = {}
      if index_searcher is None:
          index_searcher = ""
      if searcher_params is None:
          searcher_params = {}
      if index_reformer is None:
          index_reformer = ""
      if index_reformer_params is None:
          index_reformer_params = {}
  
      doc = md.DataFrame(pd.DataFrame(doc))
      query = mt.tensor(query)
  
      index = build_index(
          tensor=doc,
          need_shuffle=False,
          column_number=column_number,
          distance_metric=measure_name,
          dimension=dimension,
          index_builder=index_builder,
          index_builder_params=builder_params,
          index_converter=index_converter,
          index_converter_params=index_converter_params,
      )
      paths = index.fetch()
      if not isinstance(paths, list):
          paths = [paths]
  
      try:
          for path in paths:
              with open(path, "rb") as f:
                  assert len(f.read()) > 0
  
          pk2, distance = search_index(
              tensor=query,
              threads=threads,
              row_number=row_number,
              distance_metric=measure_name,
              dimension=dimension,
              topk=topk,
              index=index,
              index_searcher=index_searcher,
              index_searcher_params=searcher_params,
              index_reformer=index_reformer,
              index_reformer_params=index_reformer_params,
          )
          assert pk2.shape == (len(query), topk)
          assert distance.shape == (len(query), topk)
          return pk2, distance
      finally:
          for path in paths:
              os.remove(path)
  
file_path: mars/mars/learn/proxima/simple_index/tests/test_simple_index.py
imports: import os
  import tempfile
  import numpy
  import pandas
  import pytest
  from .....None import dataframe
  from .....None import tensor
  from ...core import proxima
  from ..None import build_index, search_index, recall
label_desc: Use image node_id 3 for calling a global function with example usage: build_and_query(doc, query, topk, column_number, row_number, threads, dimension, measure_name, index_builder, builder_params, index_converter, index_converter_params, index_searcher, searcher_params, index_reformer, index_reformer_params) and returns: pk2,  distance