code: def binary_search(lo, hi, f):
      """Binary searches in [lo , hi) to find
      n such that f(n) == f(lo) but f(n + 1) != f(lo).
      It is implicitly assumed and will not be checked
      that f(hi) != f(lo).
      """
  
      reference = f(lo)
  
      while lo + 1 < hi:
          mid = (lo + hi) // 2
          if f(mid) == reference:
              lo = mid
          else:
              hi = mid
      return lo
  
imports: from __future__ import absolute_import, division, print_function
  from hypothesis.internal.compat import array_or_list, hbytes, int_to_bytes, integer_types
label_desc: Use image node_id 2 for calling a global function with example usage: binary_search(lo, hi, f) and returns: lo