code: def _read_file(
      file,
      pos,
      n_lines=event_consts.EVENT_READ_LINE_COUNT_LIMIT,
      closefd=True,
  ):
      with open(file, "rb", closefd=closefd) as f:
          # The ino may be 0 on Windows.
          stat = os.stat(f.fileno())
          fid = stat.st_ino or file
          lines = []
          with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
              start = pos
              for _ in range(n_lines):
                  sep = mm.find(b"\n", start)
                  if sep == -1:
                      break
                  if (
                      sep - start
                      <= event_consts.EVENT_READ_LINE_LENGTH_LIMIT
                  ):
                      lines.append(mm[start:sep].decode("utf-8"))
                  else:
                      truncated_size = min(
                          100, event_consts.EVENT_READ_LINE_LENGTH_LIMIT
                      )
                      logger.warning(
                          "Ignored long string: %s...(%s chars)",
                          mm[start : start + truncated_size].decode(
                              "utf-8"
                          ),
                          sep - start,
                      )
                  start = sep + 1
          return ReadFileResult(
              fid, stat.st_size, stat.st_mtime, start, lines
          )
  
file_path: ray/dashboard/modules/event/event_utils.py
imports: import os
  import time
  import mmap
  import json
  import fnmatch
  import asyncio
  import itertools
  import collections
  import logging.handlers
  from ray._private.utils import get_or_create_event_loop
  from concurrent.futures import ThreadPoolExecutor
  from ray._private.utils import run_background_task
  from ray.dashboard.modules.event import event_consts
  from ray.dashboard.utils import async_loop_forever
label_desc: Use image node_id 5 for calling a global function with example usage: _read_file(file, pos, n_lines, closefd) and returns: ReadFileResult