code: def _ldm(
      model: str,
      latent_size: int,
      latent_in_channels: int,
      latent_out_channels: int,
      **kwargs: Any,
  ) -> TLoadZoo:
      kwargs["img_size"] = latent_size
      kwargs["in_channels"] = latent_in_channels
      kwargs["out_channels"] = latent_out_channels
      model_config = kwargs.setdefault("model_config", {})
      first_stage_kw = model_config.setdefault("first_stage_config", {})
      first_stage_kw.setdefault("pretrained", False)
      first_stage_model_config = first_stage_kw.setdefault(
          "model_config", {}
      )
      use_loss = first_stage_model_config.setdefault("use_loss", False)
      if not use_loss:
  
          def state_callback(
              states: tensor_dict_type,
          ) -> tensor_dict_type:
              for key in list(states.keys()):
                  if key.startswith("loss"):
                      states.pop(key)
              return states
  
          first_stage_kw["states_callback"] = state_callback
      return _load(model, **kwargs)
  
imports: from typing import Any
  from typing import Union
  from cftool.types import tensor_dict_type
  from ...schema import DLConfig
  from ...zoo.core import DLZoo
  from ...zoo.core import TPipeline
  from ...models.cv.diffusion.utils import CONCAT_TYPE
label_desc: Use image node_id 6 for calling a global function with example usage: _ldm(model, latent_size, latent_in_channels, latent_out_channels) and returns: _load, states