code: def parse_profiler_dump(operator_name, profiler_dump):
      """Parse the MXNet profiler dump output, fetch Memory profile results and
      Operator compute profiler results.
  
      Parameters
      ----------
      profiler_dump: string
          MXNet profiler output from mx.profiler.dumps() API.
  
      Returns
      -------
      map, Memory and Compute profiler results.
  
      """
      if not profiler_dump:
          raise AssertionError(
              "Invalid MXNet profiler output provided to parse!"
          )
  
      """
      MXNet profiler output from mx.profiler.dumps() API looks like below. This function parses
      this string profiler output to fetch Memory and Compute metrics.
  
      Profile Statistics.
      Note that counter items are counter values and not time units.
      Device Storage
      =================
      Name                          Total Count        Time (ms)    Min Time (ms)    Max Time (ms)    Avg Time (ms)
      ----                          -----------        ---------    -------------    -------------    -------------
      Memory: cpu/0                         100     2097152.0000     1681915.8750     2097152.0000      207618.0469
  
      MXNET_C_API
      =================
      Name                          Total Count        Time (ms)    Min Time (ms)    Max Time (ms)    Avg Time (ms)
      ----                          -----------        ---------    -------------    -------------    -------------
      MXNDArrayFree                          49           1.1220           0.0170           0.0360           0.0229
      MXAutogradBackwardEx                   50          11.5460           0.1980           0.3360           0.2309
      MXNet C API Calls                     399           1.9990           1.6010           1.9990           0.1990
      MXImperativeInvoke                     50           4.4810           0.0700           0.1330           0.0896
      MXNDArrayWaitAll                       50         769.0570          14.0200          24.5030          15.3811
      MXAutogradSetIsTraining               100           0.0190           0.0000           0.0010           0.0002
      MXAutogradSetIsRecording              100           0.0400           0.0000           0.0010           0.0004
      MXNet C API Concurrency               798           0.0000           0.0000           0.0010           0.0005
  
      operator
      =================
      Name                          Total Count        Time (ms)    Min Time (ms)    Max Time (ms)    Avg Time (ms)
      ----                          -----------        ---------    -------------    -------------    -------------
      DeleteVariable                        196           1.4490           0.0040           0.0250           0.0074
      _backward_broadcast_add               100         521.2320           4.8070           8.5970           5.2123
      SetValueOp                            100         645.8060           5.8820          10.0380           6.4581
      broadcast_add                         100         394.8910           3.5230           5.8790           3.9489
      """
  
      # String Patterns to look out for when parsing
      memory_profile_result_start = (
          "Device Storage"  # Helps identify start of Memory profile
      )
      c_api_profile_result_start = (
          "MXNET_C_API"  # Helps identify end of Memory profile
      )
  
      if operator_name == "Custom":
          operator_profile_result_start = "Custom Operator"  # Helps identify start of Custom Operator profile
      else:
          operator_profile_result_start = (
              "operator"  # Helps identify start of Operator profile
          )
  
      memory_profile_results = []
      operator_profile_results = []
  
      # Parse lines corresponding to Memory and Computation profiling
      read_memory_profile = False
      read_operator_profile = False
      for line in profiler_dump.splitlines():
          if line.startswith(memory_profile_result_start):
              read_memory_profile = True
          elif line.startswith(operator_profile_result_start):
              read_operator_profile = True
          elif line.startswith(c_api_profile_result_start):
              read_memory_profile = False
  
          if read_memory_profile:
              memory_profile_results.append(line)
          elif read_operator_profile:
              operator_profile_results.append(line)
  
      # Prepare results
      memory_profile = _get_memory_profile(memory_profile_results)
      operator_profile = _get_operator_profile(
          operator_name, operator_profile_results
      )
  
      return merge_map_list([memory_profile, operator_profile])
  
file_path: mxnet/benchmark/opperf/utils/profiler_utils.py
imports: import time
  import functools
  import numpy
  from .common_utils import merge_map_list
  from mxnet import profiler
label_desc: Use image node_id 3 for calling a global function with example usage: parse_profiler_dump(operator_name, profiler_dump) and returns: merge_map_list