code: def _append_distances(self, v, distance, candidates):
          
          if distance:
              # Normalize vector (stored vectors are normalized)
              nv = unitvec(v)
              candidates = [(x[0], x[1], self.distance.distance(x[0], nv)) for x
                              in candidates]
  
          return candidates
docs: Apply distance implementation if specified