code: def load_encoder_only(jiant_model, weights_dict):
      """Loads only encoder weights
  
      Args:
          jiant_model (JiantModel): jiant model (encoder and task models are core components).
          weights_dict (Dict): model weights.
  
      Returns:
          Dict[str, List] containing dropped keys
  
      """
      new_weights_dict = {}
      encoder_keys = [
          n for n, p in jiant_model.encoder.named_parameters()
      ]
  
      # 1. Handle core encoder
      for encoder_key in encoder_keys:
          new_key = f"encoder.{encoder_key}"
          new_weights_dict[new_key] = weights_dict[new_key]
  
      # 2. Handle taskmodel encoders:
      for taskmodel_key in jiant_model.task_to_taskmodel_map:
          for encoder_key in encoder_keys:
              new_key = f"taskmodels_dict.{taskmodel_key}.encoder.{encoder_key}"
              new_weights_dict[new_key] = weights_dict[
                  f"encoder.{encoder_key}"
              ]
  
      mismatch = jiant_model.load_state_dict(
          new_weights_dict, strict=False
      )
      assert not mismatch.unexpected_keys
      return {
          "dropped_keys": mismatch.missing_keys,
      }
  
imports: from dataclasses import dataclass
  from typing import Any
  from typing import Dict
  from typing import List
  import torch
  import torch.nn
  import transformers
  import warnings
  import jiant.proj.main.components.container_setup
  import jiant.proj.main.modeling.primary
  import jiant.utils.python.strings
  from jiant.proj.main.modeling.heads import JiantHeadFactory
  from jiant.proj.main.modeling.taskmodels import JiantTaskModelFactory, Taskmodel, MLMModel
  from jiant.shared.model_resolution import ModelArchitectures
  from jiant.tasks.core import Task
label_desc: Use image node_id 6 for calling a global function with example usage: load_encoder_only(jiant_model, weights_dict) and returns: dict