docstr: Analyse memory event in the nodetress.
code: def parse(self, nodetrees):  # noqa: C901
      r"""
      Analyse memory event in the nodetress.
      """
      thread2hostnodes = traverse_tree(nodetrees)
      for threadid, host_nodes in thread2hostnodes.items():
          for host_node in host_nodes[1:]:  # skip root node
              if host_node.type == "OperatorInner":
                  continue
              if host_node.type == "Operator":
                  for child in host_node.children_node:
                      self._analyse_node_memory(host_node.name, child)
              self._analyse_node_memory(host_node.name, host_node)
  
      # pair for memory events
      for device_type, memory_events in self.memory_events.items():
          max_size = 0
          for (
              addr,
              memory_type,
          ), memory_lists in memory_events.items():
              memory_lists = sorted(memory_lists, key=lambda x: x[0])
              paired_results = []
              for memory_list in memory_lists:
                  (
                      timestamp,
                      memory_type,
                      hostnodename,
                      size,
                  ) = memory_list
                  if (
                      memory_type == "Allocate"
                      or memory_type == "ReservedAllocate"
                  ):
                      if size > max_size:
                          max_size = size
                      if memory_type == "Allocate":
                          paired_results.append(
                              [
                                  addr,
                                  "Allocated",
                                  hostnodename,
                                  timestamp,
                                  None,
                                  None,
                                  size,
                              ]
                          )
                      else:
                          paired_results.append(
                              [
                                  addr,
                                  "ReservedAllocate",
                                  hostnodename,
                                  timestamp,
                                  None,
                                  None,
                                  size,
                              ]
                          )
                  elif (
                      memory_type == "Free"
                      or memory_type == "ReservedFree"
                  ):
                      if -size > max_size:
                          max_size = -size
                      if paired_results:
                          if paired_results[-1][-3] is None:
                              paired_results[-1][-3] = hostnodename
                              paired_results[-1][-2] = timestamp
                              self.paired_events[device_type].append(
                                  paired_results.pop()
                              )
                          else:
                              if memory_type == "Free":
                                  paired_results.append(
                                      [
                                          addr,
                                          "Allocated",
                                          None,
                                          None,
                                          hostnodename,
                                          timestamp,
                                          -size,
                                      ]
                                  )
                              else:
                                  paired_results.append(
                                      [
                                          addr,
                                          "ReservedAllocate",
                                          None,
                                          None,
                                          hostnodename,
                                          timestamp,
                                          -size,
                                      ]
                                  )
                              self.paired_events[device_type].append(
                                  paired_results.pop()
                              )
                      else:
                          if memory_type == "Free":
                              paired_results.append(
                                  [
                                      addr,
                                      "Allocated",
                                      None,
                                      None,
                                      hostnodename,
                                      timestamp,
                                      -size,
                                  ]
                              )
                          else:
                              paired_results.append(
                                  [
                                      addr,
                                      "ReservedAllocate",
                                      None,
                                      None,
                                      hostnodename,
                                      timestamp,
                                      -size,
                                  ]
                              )
                          self.paired_events[device_type].append(
                              paired_results.pop()
                          )
  
              self.paired_events[device_type].extend(paired_results)
          self.size_ranges[device_type] = (0, max_size)
  
file_path: VisualDL/visualdl/component/profiler/parser/memory_parser.py
imports: import collections
  from .utils import traverse_tree
label_desc: Use image node_id 2 for calling the MemoryParser obj's underlying member method code with example usage: obj.parse(nodetrees) without return types