code: def leader_is_reelected(count):
      current_leader = None
      current_leader_count = 0
  
      def leader_is_reelected(uri, previous_leader):
          r = requests.get(f"{uri}/cluster")
          assert_http_ok(r)
  
          leader = r.json()["result"]["raft_info"]["leader"]
  
          if leader != previous_leader and not leader is None:
              nonlocal current_leader
              nonlocal current_leader_count
  
              if leader == current_leader:
                  current_leader_count += 1
              else:
                  current_leader = leader
                  current_leader_count = 1
  
              if current_leader_count >= count:
                  return True
  
          return False
  
      return leader_is_reelected
  
imports: import pathlib
  import urllib
  import time
  from .utils import *
  from .assertions import assert_http_ok
label_desc: Use image node_id 2 for calling a global function with example usage: leader_is_reelected(count) and returns: leader_is_reelected, False, True