class_docstr: Generates values of X between A & B to invoke on an external predicate F(X) to
  discover the largest X for which F(X) is true. Uses binary search to minimize the
  number of invocations of F. Assumes F is a step function, i.e. if F(X) is false,
  there is no point trying F(X+1).
class_docstr_tok: ["Generates","values","of","X","between","A","&","B","to","invoke","on","an","external","predicate","F","(","X",")","to","discover","the","largest","X","for","which","F","(","X",")","is","true",".","Uses","binary","search","to","minimize","the","number","of","invocations","of","F.","Assumes","F","is","a","step","function",",","i.e",".","if","F","(","X",")","is","false",",","there","is","no","point","trying","F","(","X+1",")","."]
docstr: next() returns the next value to probe, given the result of the prior probe.
  The first time next() is invoked the prior_result is ignored. Returns None if
  entire range explored or threshold reached.
docstr_tok: ["next","(",")","returns","the","next","value","to","probe",",","given","the","result","of","the","prior","probe",".","The","first","time","next","(",")","is","invoked","the","prior_result","is","ignored",".","Returns","None","if","entire","range","explored","or","threshold","reached","."]
code: def next(self, prior_result: bool) -> Optional[int]:
      """next() returns the next value to probe, given the result of the prior probe.
      The first time next() is invoked the prior_result is ignored. Returns None if
      entire range explored or threshold reached."""
      if self.right - self.left < self.tolerance:
          return None
  
      mid = self._mid()
      if self.first:
          self.first = False
          return mid
  
      if prior_result:
          self.left = mid + 1
      else:
          self.right = mid - 1
      if self.right - self.left < self.tolerance:
          return None
  
      return self._mid()
  
file_path: torchrec/torchrec/distributed/planner/utils.py
imports: import operator
  from functools import reduce
  from typing import Any, cast, Dict, Iterable, List, Optional, Type, Union
  import torch
  from torchrec.distributed.planner.types import Perf, ShardingOption, Storage
  from torchrec.distributed.types import ShardingType
label_desc: Use image node_id 2 for calling the BinarySearchPredicate obj's underlying member method code with example usage: obj.next(prior_result) and returns: self, None, mid, None