code: def convert(
      inp: Union[str, tensor_dict_type],
      api: DiffusionAPI,
      *,
      vae_inp: Optional[Union[str, tensor_dict_type]] = None,
      load: bool = False,
      use_mapping: bool = True,
  ) -> tensor_dict_type:
      inp = _get_inp(inp, vae_inp)
      with api.load_context() as m:
          md = m.state_dict()
          if not use_mapping:
              nd = _convert(inp, md)
          else:
              nd = _convert_with_key_mapping(inp, md)
          if load:
              m.load_state_dict(nd)
      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 7 for calling a global function with example usage: convert(inp, api) and returns: nd