class_docstr: Class to construct and perform search using a BKTree.
docstr: Get candidates for checking if the query falls within the distance tolerance. Sets a validity flag if the input
  candidate BKTree node is valid (distance to this candidate is within the distance tolerance from the query.)
  
  Args:
      query: The hash for which retrievals are needed.
      candidate_obj: A BKTree object which is a candidate for being checked as valid.
      tolerance: Distance within which the candidate is considered valid.
  
  Returns:
      new candidates to examine, validity flag indicating whether current candidate is within the distance
      tolerance, distance of the current candidate from the query hash.
docstr_tok: ["Get","candidates","for","checking","if","the","query","falls","within","the","distance","tolerance",".","Sets","a","validity","flag","if","the","input","candidate","BKTree","node","is","valid","(","distance","to","this","candidate","is","within","the","distance","tolerance","from","the","query",".",")","Args",":","query",":","The","hash","for","which","retrievals","are","needed",".","candidate_obj",":","A","BKTree","object","which","is","a","candidate","for","being","checked","as","valid",".","tolerance",":","Distance","within","which","the","candidate","is","considered","valid",".","Returns",":","new","candidates","to","examine",",","validity","flag","indicating","whether","current","candidate","is","within","the","distance","tolerance",",","distance","of","the","current","candidate","from","the","query","hash","."]
code: def _get_next_candidates(
      self, query: str, candidate_obj: BkTreeNode, tolerance: int
  ) -> Tuple[list, int, float]:
      """
      Get candidates for checking if the query falls within the distance tolerance. Sets a validity flag if the input
      candidate BKTree node is valid (distance to this candidate is within the distance tolerance from the query.)
  
      Args:
          query: The hash for which retrievals are needed.
          candidate_obj: A BKTree object which is a candidate for being checked as valid.
          tolerance: Distance within which the candidate is considered valid.
  
      Returns:
          new candidates to examine, validity flag indicating whether current candidate is within the distance
          tolerance, distance of the current candidate from the query hash.
      """
      dist = self.distance_function(candidate_obj.node_value, query)
      if dist <= tolerance:
          validity = 1
      else:
          validity = 0
      search_range_dist = list(
          range(dist - tolerance, dist + tolerance + 1)
      )
      candidate_children = candidate_obj.children
      candidates = [
          k
          for k in candidate_children.keys()
          if candidate_children[k] in search_range_dist
      ]
      return candidates, validity, dist
  
file_path: imagededup/imagededup/handlers/search/bktree.py
imports: import copy
  from typing import Callable, Dict, Tuple
label_desc: Use image node_id 4 for calling the BKTree obj's underlying member method code with example usage: obj._get_next_candidates(query, candidate_obj, tolerance) and returns: candidates,  validity,  dist