code: def report_raylet_error_logs(log_dir: str, gcs_address: str):
      log_path = os.path.join(log_dir, "raylet.out")
      error = False
      msg = "Raylet is terminated. "
      try:
          with open(log_path, "r", encoding="utf-8") as f:
              # Seek to _RAYLET_LOG_MAX_TAIL_SIZE from the end if the
              # file is larger than that.
              f.seek(0, io.SEEK_END)
              pos = max(0, f.tell() - _RAYLET_LOG_MAX_TAIL_SIZE)
              f.seek(pos, io.SEEK_SET)
              # Read remaining logs by lines.
              raylet_logs = f.readlines()
              # Assume the SIGTERM message must exist within the last
              # _RAYLET_LOG_MAX_TAIL_SIZE of the log file.
              if any(
                  "Raylet received SIGTERM" in line
                  for line in raylet_logs
              ):
                  msg += "Termination is graceful."
                  logger.info(msg)
              else:
                  msg += (
                      "Termination is unexpected. Possible reasons "
                      "include: (1) SIGKILL by the user or system "
                      "OOM killer, (2) Invalid memory access from "
                      "Raylet causing SIGSEGV or SIGBUS, "
                      "(3) Other termination signals. "
                      f"Last {_RAYLET_LOG_MAX_PUBLISH_LINES} lines "
                      "of the Raylet logs:\n"
                  )
                  msg += "    " + "    ".join(
                      raylet_logs[-_RAYLET_LOG_MAX_PUBLISH_LINES:]
                  )
                  error = True
      except Exception as e:
          msg += f"Failed to read Raylet logs at {log_path}: {e}!"
          logger.exception(msg)
          error = True
      if error:
          logger.error(msg)
          # TODO: switch to async if necessary.
          ray._private.utils.publish_error_to_driver(
              ray_constants.RAYLET_DIED_ERROR,
              msg,
              gcs_publisher=ray._raylet.GcsPublisher(
                  address=gcs_address
              ),
          )
      else:
          logger.info(msg)
  
file_path: ray/python/ray/_private/process_watcher.py
imports: import asyncio
  import io
  import logging
  import sys
  import os
  from concurrent.futures import ThreadPoolExecutor
  import ray
  from ray.dashboard.consts import _PARENT_DEATH_THREASHOLD
  import ray.dashboard.consts
  import ray._private.ray_constants
  from ray._private.utils import run_background_task
  import psutil
label_desc: Use image node_id 3 for calling a global function with example usage: report_raylet_error_logs(log_dir, gcs_address) without return types