code: def _find_job_driver_and_ray_error_logs(
      tmpdir: str,
  ) -> Tuple[Optional[str], Optional[str]]:
      # Ignored some ray files that do not crash ray despite having exceptions
      ignored_ray_files = [
          "monitor.log",
          "event_AUTOSCALER.log",
          "event_JOBS.log",
      ]
      error_output = None
      job_driver_output = None
      matched_pattern_count = 0
      for root, _, files in os.walk(tmpdir):
          files.sort()  # Make the iteration order deterministic.
          for file in files:
              if file in ignored_ray_files:
                  continue
              with open(os.path.join(root, file)) as lines:
                  output = "".join(
                      deque(lines, maxlen=3 * LAST_LOGS_LENGTH)
                  )
                  # job-driver logs
                  if file.startswith("job-driver-"):
                      job_driver_output = output
                      continue
                  # ray error logs, favor those that match with the most number of
                  # error patterns
                  this_match = len(
                      [
                          error
                          for error in ERROR_LOG_PATTERNS
                          if error in output
                      ]
                  )
                  if this_match > matched_pattern_count:
                      error_output = output
                      matched_pattern_count = this_match
      return job_driver_output, error_output
  
imports: import os
  import time
  import subprocess
  import tempfile
  from collections import deque
  from contextlib import contextmanager
  from typing import Any, Dict, Optional, Tuple, List
  from anyscale.sdk.anyscale_client.models import CreateProductionJob, HaJobStates
  from ray_release.anyscale_util import LAST_LOGS_LENGTH, get_cluster_name
  from ray_release.cluster_manager.cluster_manager import ClusterManager
  from ray_release.exception import CommandTimeout, JobStartupTimeout, JobStartupFailed
  from ray_release.logger import logger
  from ray_release.signal_handling import register_handler, unregister_handler
  from ray_release.util import ANYSCALE_HOST, ERROR_LOG_PATTERNS, exponential_backoff_retry, anyscale_job_url, format_link
label_desc: Use image node_id 16 for calling the AnyscaleJobManager obj's underlying member method code with example usage: obj._find_job_driver_and_ray_error_logs(tmpdir) and returns: job_driver_output,  error_output