code: def _convert_with_key_mapping(
      d: tensor_dict_type,
      md: tensor_dict_type,
  ) -> tensor_dict_type:
      d, md = map(shallow_copy_dict, [d, md])
      with open(
          download_static("sd_mapping", extension="json"), "r"
      ) as f:
          mapping = json.load(f)
      nd = _convert_cond_stage(d, md)
      for k, mk in mapping.items():
          nd[mk] = d[k]
      for k, v in md.items():
          nd.setdefault(k, v)
      return nd
  
imports: import json
  import torch
  from torch import Tensor
  from typing import Dict
  from typing import List
  from typing import Union
  from typing import Optional
  from cftool.misc import shallow_copy_dict
  from cftool.array import tensor_dict_type
  from ..misc.toolkit import get_tensors
  from ..misc.toolkit import download_static
  from ..api.cv.diffusion import DiffusionAPI
label_desc: Use image node_id 5 for calling a global function with example usage: _convert_with_key_mapping(d, md) and returns: nd