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: A = lower boundary (inclusive)
  B = upper boundary (inclusive)
  tolerance = stop search early if remaining search range is less than tolerance
docstr_tok: ["A","=","lower","boundary","(","inclusive",")","B","=","upper","boundary","(","inclusive",")","tolerance","=","stop","search","early","if","remaining","search","range","is","less","than","tolerance"]
code: def __init__(self, A: int, B: int, tolerance: int) -> None:
      """A = lower boundary (inclusive)
      B = upper boundary (inclusive)
      tolerance = stop search early if remaining search range is less than tolerance
      """
      self.left = A
      self.right = B
      self.tolerance = tolerance
      self.first = True
  
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 1 to create a new BinarySearchPredicate object  with example: obj = BinarySearchPredicate(A, B, tolerance)