code: def _merge_resource_dict(
      cls, resources, skip=[], methods={}, default_method=max
  ):
      grouped = {}
      for job in resources:
          # Wrap every value in job with a list so that lists can be merged later
          job_l = {k: [v] for k, v in job.items()}
  
          # Merge two dicts together, merging key-values found in both into a
          # list. Code adapted from
          # https://stackoverflow.com/a/11012181/16980632
          grouped = {
              **grouped,
              **job_l,
              **{
                  k: grouped[k] + job_l[k]
                  for k in grouped.keys() & job_l
              },
          }
  
      ret = {}
      for res, values in grouped.items():
          if res in skip:
              continue
  
          if cls._is_string_resource(res, values):
              ret[res] = values[0]
          elif res in methods:
              ret[res] = methods[res](values)
          else:
              ret[res] = default_method(values)
      return ret
  
imports: from collections import UserDict, defaultdict
  import itertools
  import operator
  import re
  import tempfile
  from snakemake.exceptions import ResourceScopesException, WorkflowError
  from snakemake.common.tbdstring import TBDString
label_desc: Use image node_id 4 for calling the GroupResources obj's underlying member method code with example usage: obj._merge_resource_dict(cls, resources, skip, methods, default_method) and returns: ret