code: def infer_resources(name, value, resources: dict):
      """Infer resources from a given one, if possible."""
      from humanfriendly import (
          parse_size,
          parse_timespan,
          InvalidTimespan,
          InvalidSize,
      )
  
      if (name == "mem" or name == "disk") and isinstance(value, str):
          inferred_name = f"{name}_mb"
          try:
              in_bytes = parse_size(value)
          except InvalidSize:
              raise WorkflowError(
                  f"Cannot parse mem or disk value into size in MB for setting {inferred_name} resource: {value}"
              )
          resources[inferred_name] = max(
              int(round(in_bytes / 1000 / 1000)), 1
          )
      elif name == "runtime" and isinstance(value, str):
          try:
              resources["runtime"] = max(
                  int(round(parse_timespan(value) / 60)), 1
              )
          except InvalidTimespan:
              raise WorkflowError(
                  f"Cannot parse runtime value into minutes for setting runtime resource: {value}"
              )
  
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 3 for calling a global function with example usage: infer_resources(name, value, resources) without return types