code: def bisect(cmd):
      last_good = 0
      first_bad = 10000
      skips = set()
  
      # Test if there are any unskipped commits in (last_good, first_bad)
      def keep_going():
          for limit in range(last_good + 1, first_bad):
              if limit not in skips:
                  return True
          return False
  
      while keep_going():
          test_limit = test_mid = (last_good + first_bad) // 2
          val = -1
  
          # Scan forward from mid towards bad.
          while test_limit <= first_bad and val == -1:
              val = test(cmd, test_limit)
              if val == -1:
                  skips.add(test_limit)
                  test_limit = test_limit + 1
  
          # If everything in [mid, bad] skipped, scan back towards good.
          if val == -1:
              test_limit = test_mid - 1
              while test_limit >= last_good and val == -1:
                  val = test(cmd, test_limit)
                  if val == -1:
                      skips.add(test_limit)
                      test_limit = test_limit - 1
  
          if val == 0:
              first_bad = test_limit
          elif val == 1:
              last_good = test_limit
  
      print(f"last good: {last_good}, first bad: {first_bad}")
  
label_desc: Use image node_id 2 for calling a global function with example usage: bisect(cmd) and returns: False, True