code: def check_system_state(
      instance_id,
      system_status="ok",
      instance_status="ok",
      region=DEFAULT_REGION,
  ):
      """
      Compares the system state (Health Checks).
      Retries 96 times with 10 seconds gap between retries
      :param instance_id: Instance ID to be queried
      :param system_status: Expected system state
      :param instance_status: Expected instance state
      :param region: Region where query will be performed
      :return: <tuple> System state and Instance state of instance with matching instance ID
      """
      instance_state = get_system_state(instance_id, region=region)
      if (
          system_status != instance_state[0]
          or instance_status != instance_state[1]
      ):
          raise Exception(
              "Instance {} not in \
                           required state".format(
                  instance_id
              )
          )
      return instance_state
  
imports: import boto3
  import os
  import time
  import re
  from inspect import signature
  import random
  from retrying import retry
  from fabric2 import Connection
  from botocore.config import Config
  from botocore.exceptions import ClientError
  from invoke import run
  from invoke.context import Context
  from .None import DEFAULT_REGION, LOGGER
label_desc: Use image node_id 12 for calling a global function with example usage: check_system_state(instance_id, system_status, instance_status, region) and returns: instance_state