code: def get_topk(distances, indices, k, get_largest):
      def fn(mat, s, e):
          D, I = torch.topk(mat, k, largest=get_largest, dim=1)
          distances[s:e] = D
          indices[s:e] = I
  
      return fn
  
imports: import numpy
  import torch
  from ..distances import BatchedDistance, CosineSimilarity
  from .None import common_functions
label_desc: Use image node_id 8 for calling a global function with example usage: get_topk(distances, indices, k, get_largest) and returns: fn