code: def _fetch_state(aml_id, properties=None, verbosity=None):
      state_json = h2o.api(
          "GET /99/AutoML/%s" % aml_id, data=dict(verbosity=verbosity)
      )
      project_name = state_json["project_name"]
      if project_name is None:
          raise H2OValueError(
              "No AutoML instance with id {}.".format(aml_id)
          )
  
      leaderboard_list = [
          key["name"] for key in state_json["leaderboard"]["models"]
      ]
      leader_id = (
          leaderboard_list[0]
          if (
              leaderboard_list is not None and len(leaderboard_list) > 0
          )
          else None
      )
  
      should_fetch = (
          lambda prop: properties is None or prop in properties
      )
  
      leader = None
      if should_fetch("leader"):
          leader = (
              h2o.get_model(leader_id)
              if leader_id is not None
              else None
          )
  
      leaderboard = None
      if should_fetch("leaderboard"):
          leaderboard = _fetch_table(
              state_json["leaderboard_table"],
              key=project_name + "_leaderboard",
              progress_bar=False,
          )
  
      event_log = None
      if should_fetch("event_log"):
          event_log = _fetch_table(
              state_json["event_log_table"],
              key=project_name + "_eventlog",
              progress_bar=False,
          )
  
      return dict(
          project_name=project_name,
          json=state_json,
          leader_id=leader_id,
          leader=leader,
          leaderboard=leaderboard,
          event_log=event_log,
      )
  
imports: import h2o
  from h2o.base import Keyed
  from h2o.exceptions import H2OValueError
  from h2o.job import H2OJob
  from h2o.model import ModelBase
  from h2o.utils.compatibility import *
  from h2o.utils.typechecks import assert_is_type, is_type
label_desc: Use image node_id 3 for calling a global function with example usage: _fetch_state(aml_id, properties, verbosity) and returns: dict