code: def test_core_events(shutdown_only):
      # Test events recorded from core RAY_EVENT APIs.
      ray.init()
  
      @ray.remote
      class Actor:
          def getpid(self):
              return os.getpid()
  
      a = Actor.remote()
      pid = ray.get(a.getpid.remote())
      os.kill(pid, 9)
      s = time.time()
  
      def verify():
          events = list_cluster_events(
              filters=[("source_type", "=", "RAYLET")]
          )
          print(events)
          assert len(list_cluster_events()) == 1
          event = events[0]
          assert event["severity"] == "ERROR"
          datetime_str = event["time"]
          datetime_obj = datetime.strptime(
              datetime_str, "%Y-%m-%d %H:%M:%S"
          )
          timestamp = time.mktime(datetime_obj.timetuple())
  
          # Make sure timestamp is not incorrect. Add sufficient buffer (60 seconds)
          assert abs(timestamp - s) < 60
          assert (
              "A worker died or was killed while executing "
              "a task by an unexpected system error" in event["message"]
          )
          return True
  
      wait_for_condition(verify)
      pprint(list_cluster_events())
  
imports: import os
  import sys
  import time
  import json
  import copy
  import logging
  import requests
  import asyncio
  import random
  import tempfile
  import socket
  from pprint import pprint
  from datetime import datetime
  import pytest
  import numpy
  import ray
  from ray.util.state import list_cluster_events
  from ray._private.utils import binary_to_hex
  from ray.cluster_utils import AutoscalingCluster
  from ray._private.event.event_logger import filter_event_by_level, get_event_logger
  from ray.dashboard.tests.conftest import *
  from ray.dashboard.modules.event import event_consts
  from ray.core.generated import event_pb2
  from ray._private.test_utils import format_web_url, wait_until_server_available, wait_for_condition
  from ray.dashboard.modules.event.event_utils import monitor_events
  from ray.job_submission import JobSubmissionClient
label_desc: Use image node_id 9 for calling a global function with example usage: test_core_events(shutdown_only) and returns: True, os