code: def get_all_events(
      kineto_events: List[_KinetoEvent],
      function_events: profiler_util.EventList,
  ) -> Tuple[
      List[_KinetoEvent],
      List[profiler_util.FunctionEvent],
      List[List[Union[_KinetoEvent, bool]]],
      List[List[Union[_KinetoEvent, bool]]],
  ]:
      """Return main Kineto and function events, memory and OOM events for functions/code blocks tagged in
      LudwigProfiler.
  
      :param kineto_events: list of Kineto Events.
      :param function_events: list of function events.
      """
      # LUDWIG_TAG is prepended to LudwigProfiler tags. This edited tag is passed in to `torch.profiler.record_function`
      # so we can easily retrieve events for code blocks wrapped with LudwigProfiler.
      main_function_events = [
          evt for evt in function_events if LUDWIG_TAG in evt.name
      ]
      main_kineto_events = [
          event for event in kineto_events if LUDWIG_TAG in event.name()
      ]
      memory_events = [
          [event, False]
          for event in kineto_events
          if profiler_util.MEMORY_EVENT_NAME in event.name()
      ]
      # profiler_util.OUT_OF_MEMORY_EVENT_NAME seems to only be in newer versions of torch.
      out_of_memory_events = [
          [event, False]
          for event in kineto_events
          if "[OutOfMemory]" in event.name()
      ]
      return (
          main_kineto_events,
          main_function_events,
          memory_events,
          out_of_memory_events,
      )
  
file_path: ludwig/ludwig/benchmarking/reporting.py
imports: from collections import Counter, defaultdict
  from statistics import mean
  from typing import Any, Dict, List, Tuple, Union
  import torch
  from torch._C._autograd import _KinetoEvent
  from torch.autograd import DeviceType, profiler_util
  from ludwig.benchmarking.profiler_dataclasses import DeviceUsageMetrics, SystemResourceMetrics, TorchProfilerMetrics
  from ludwig.constants import LUDWIG_TAG
label_desc: Use image node_id 8 for calling a global function with example usage: get_all_events(kineto_events, function_events) and returns: main_kineto_events,  main_function_events,  memory_events,  out_of_memory_events