code: def build_index(
      tensor,
      dimension=None,
      index_path=None,
      column_number=None,
      need_shuffle=False,
      distance_metric="SquaredEuclidean",
      index_builder="SsgBuilder",
      index_builder_params=None,
      index_converter=None,
      index_converter_params=None,
      topk=None,
      storage_options=None,
      run=True,
      session=None,
      run_kwargs=None,
  ):
      tensor = validate_tensor(tensor)
      if tensor.dtype not in available_numpy_dtypes:
          raise ValueError(
              f"Dtype to build index should be one of {available_numpy_dtypes}, "
              f"got {tensor.dtype}"
          )
  
      if dimension is None:
          dimension = tensor.shape[1]
      if index_builder_params is None:
          index_builder_params = {}
      if index_converter_params is None:
          index_converter_params = {}
  
      if need_shuffle:
          tensor = mt.random.permutation(tensor)
  
      op = ProximaBuilder(
          distance_metric=distance_metric,
          index_path=index_path,
          dimension=dimension,
          column_number=column_number,
          index_builder=index_builder,
          index_builder_params=index_builder_params,
          index_converter=index_converter,
          index_converter_params=index_converter_params,
          topk=topk,
          storage_options=storage_options,
      )
      result = op(tensor)
      if run:
          return result.execute(
              session=session, **(run_kwargs or dict())
          )
      else:
          return result
  
imports: import itertools
  import logging
  import os
  import pickle
  import tempfile
  import uuid
  import numpy
  from ....None import opcodes
  from ....None import tensor
  from ....lib.filesystem import get_fs
  from ....core import OutputType
  from ....core.context import get_context
  from ....core.operand import OperandStage
  from ....serialization.serializables import StringField, Int32Field, Int64Field, DictField, BytesField, TupleField, DataTypeField
  from ....utils import has_unknown_shape, Timer
  from ...operands import LearnOperand, LearnOperandMixin
  from ..core import proxima, get_proxima_type, validate_tensor, available_numpy_dtypes, rechunk_tensor, build_mmap_chunks
label_desc: Use image node_id 1 for calling a global function with example usage: build_index(tensor, dimension, index_path, column_number, need_shuffle, distance_metric, index_builder, index_builder_params, index_converter, index_converter_params, topk, storage_options, run, session, run_kwargs) and returns: result, result