class_docstr: Hold all parsed data to serve for user requests.
class_docstr_tok: ["Hold","all","parsed","data","to","serve","for","user","requests","."]
code: def get_memory_events(
      self,
      device_type,
      min_size=0,
      max_size=float("inf"),
      search_name=None,
      time_unit="ms",
  ):
      if not self.memory_parser:
          return
      data = {}
      data["column_name"] = [
          "MemoryAddr",
          "MemoryType",
          "AllocatedEvent",
          "AllocatedTimestamp",
          "FreeEvent",
          "FreeTimestamp",
          "Duration",
          "Size",
      ]
      data["data"] = []
      paired_event_list = self.paired_events[device_type]
  
      def filter_func(item):
          nonlocal min_size
          nonlocal max_size
          nonlocal search_name
          size = format_memory(item[-1], "KB")
          if not search_name:
              if size >= min_size and size <= max_size:
                  return True
          else:
              if size >= min_size and size <= max_size:
                  if item[2]:
                      if search_name in item[2]:
                          return True
                  if item[4]:
                      if search_name in item[4]:
                          return True
          return False
  
      paired_event_list = filter(filter_func, paired_event_list)
      paired_event_list = sorted(paired_event_list, key=lambda x: x[-1])
      if not paired_event_list:
          return data
      duration = None
      for item in paired_event_list:
          if item[3] and item[5]:
              duration = item[5] - item[3]
          else:
              duration = None
          data["data"].append(
              {
                  "MemoryAddr": item[0],
                  "MemoryType": item[1],
                  "AllocatedEvent": item[2],
                  "AllocatedTimestamp": format_time(item[3], time_unit)
                  if item[3]
                  else None,
                  "FreeEvent": item[4],
                  "FreeTimestamp": format_time(item[5], time_unit)
                  if item[5]
                  else None,
                  "Duration": format_time(duration, time_unit)
                  if duration is not None
                  else None,
                  "Size": format_memory(item[6], "KB"),
              }
          )
      return data
  
imports: from collections import defaultdict
  from collections import OrderedDict
  from .parser.distributed_parser import DistributedParser
  from .parser.kernel_parser import KernelParser
  from .parser.memory_parser import MemoryParser
  from .parser.operator_parser import OperatorParser
  from .parser.overview_parser import CPUType
  from .parser.overview_parser import GPUType
  from .parser.overview_parser import OverviewParser
  from .parser.trace_parser import TraceParser
  from .parser.utils import format_float
  from .parser.utils import format_memory
  from .parser.utils import format_ratio
  from .parser.utils import format_time
  from .parser.utils import traverse_tree
label_desc: Use image node_id 18 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_memory_events(device_type, min_size, max_size, search_name, time_unit) and returns: data, False, data, True, True, True