code: def _load_pretrained_model(
      self, state_dict, ignore_mismatched_sizes=False
  ):
      state_dict = self._state_key_mapping(state_dict)
      model_state_dict = self.state_dict()
      loaded_keys = [k for k in state_dict.keys()]
      expected_keys = list(model_state_dict.keys())
      original_loaded_keys = loaded_keys
      missing_keys = list(set(expected_keys) - set(loaded_keys))
      unexpected_keys = list(set(loaded_keys) - set(expected_keys))
  
      def _find_mismatched_keys(
          state_dict,
          model_state_dict,
          loaded_keys,
          ignore_mismatched_sizes,
      ):
          mismatched_keys = []
          if ignore_mismatched_sizes:
              for checkpoint_key in loaded_keys:
                  model_key = checkpoint_key
  
                  if (
                      model_key in model_state_dict
                      and state_dict[checkpoint_key].shape
                      != model_state_dict[model_key].shape
                  ):
                      mismatched_keys.append(
                          (
                              checkpoint_key,
                              state_dict[checkpoint_key].shape,
                              model_state_dict[model_key].shape,
                          )
                      )
                      del state_dict[checkpoint_key]
          return mismatched_keys
  
      if state_dict["encoder.mid.attn_1.q.weight"].shape == torch.Size(
          [512, 512]
      ):
          for key in [
              "encoder.mid.attn_1.q.weight",
              "decoder.mid.attn_1.q.weight",
              "encoder.mid.attn_1.v.weight",
              "decoder.mid.attn_1.v.weight",
              "encoder.mid.attn_1.k.weight",
              "decoder.mid.attn_1.k.weight",
              "encoder.mid.attn_1.proj_out.weight",
              "decoder.mid.attn_1.proj_out.weight",
          ]:
              state_dict[key] = (
                  state_dict[key].unsqueeze(2).unsqueeze(3)
              )
  
      if state_dict is not None:
          # Whole checkpoint
          mismatched_keys = _find_mismatched_keys(
              state_dict,
              model_state_dict,
              original_loaded_keys,
              ignore_mismatched_sizes,
          )
          error_msgs = self._load_state_dict_into_model(state_dict)
      return missing_keys, unexpected_keys, mismatched_keys, error_msgs
  
imports: from contextlib import contextmanager
  import pytorch_lightning
  import torch
  import torch.nn.functional
  from nemo.collections.multimodal.modules.stable_diffusion.diffusionmodules.model import Decoder, Encoder
  from nemo.collections.multimodal.modules.stable_diffusion.distributions.distributions import DiagonalGaussianDistribution
  from nemo.collections.multimodal.parts.stable_diffusion.utils import instantiate_from_config
label_desc: Use image node_id 3 for calling the AutoencoderKL obj's underlying member method code with example usage: obj._load_pretrained_model(state_dict, ignore_mismatched_sizes) and returns: missing_keys,  unexpected_keys,  mismatched_keys,  error_msgs, mismatched_keys