code: def convert_v2(
      inp: Union[str, tensor_dict_type],
      api: DiffusionAPI,
      *,
      vae_inp: Optional[Union[str, tensor_dict_type]] = None,
      load: bool = False,
  ) -> tensor_dict_type:
      inp = _get_inp(inp, vae_inp)
      for k in [
          "log_one_minus_alphas_cumprod",
          "sqrt_recip_alphas_cumprod",
          "sqrt_recipm1_alphas_cumprod",
      ]:
          inp.pop(k)
      with api.load_context() as m:
          md = m.state_dict()
          nd = {}
          for k in [
              "condition_model.m.text_projection.bias",
              "condition_model.m.text_transformer.attention_mask",
          ]:
              nd[k] = md.pop(k)
          with open(
              download_static("sd_v2_mapping", extension="json"), "r"
          ) as f:
              mapping = json.load(f)
          for k, mk in mapping.items():
              v = inp[k]
              if mk == "condition_model.m.text_projection.weight":
                  v = v.t()
              nd[mk] = v.view(md[mk].shape)
          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 8 for calling a global function with example usage: convert_v2(inp, api) and returns: nd