class_docstr: MemUsageParam is used to merge memory usage code map
class_docstr_tok: ["MemUsageParam","is","used","to","merge","memory","usage","code","map"]
code: def addInPlace(
      value1: Optional[CodeMapDict], value2: Optional[CodeMapDict]
  ) -> Optional[CodeMapDict]:
      # An example value looks as below
      # {'<command-1598004922717618>': [(3, (144.2578125, 144.2578125, 1)),
      #   (4, (0.0, 144.2578125, 1))]}
      if value1 is None or len(value1) == 0:
          return value2
      if value2 is None or len(value2) == 0:
          return value1
  
      # value1, value2 should have same keys - file name
      for filename in value1:
          l1 = cast(List[LineProfile], value1.get(filename))
          l2 = cast(List[LineProfile], value2.get(filename))
          c1 = dict((k, v) for k, v in l1)
          c2 = dict((k, v) for k, v in l2)
          udf_code_map: Dict[int, Optional[MemoryTuple]] = {}
          for lineno in c1:
              if c1[lineno] and c2[lineno]:
                  # c1, c2 should have same keys - line number
                  udf_code_map[lineno] = (
                      cast(MemoryTuple, c1[lineno])[0]
                      + cast(MemoryTuple, c2[lineno])[0],  # increment
                      cast(MemoryTuple, c1[lineno])[1]
                      + cast(MemoryTuple, c2[lineno])[1],  # mem_usage
                      cast(MemoryTuple, c1[lineno])[2]
                      + cast(MemoryTuple, c2[lineno])[2],  # occurrences
                  )
              elif c1[lineno]:
                  udf_code_map[lineno] = cast(MemoryTuple, c1[lineno])
              elif c2[lineno]:
                  udf_code_map[lineno] = cast(MemoryTuple, c2[lineno])
              else:
                  udf_code_map[lineno] = None
          value1[filename] = [(k, v) for k, v in udf_code_map.items()]
      return value1
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TYPE_CHECKING, Union, cast
  import cProfile
  import inspect
  import pstats
  import linecache
  import os
  import atexit
  import sys
  import warnings
  from pyspark.accumulators import AccumulatorParam
  from pyspark.errors import PySparkRuntimeError
label_desc: Use image node_id 2 for calling the MemUsageParam obj's underlying member method code with example usage: obj.addInPlace(value1, value2) and returns: value1, value2, value1