code: def delegate_load(jiant_model, weights_dict: dict, load_mode: str):
      """Load weights dict into JiantModel according to specified loading mode.
  
      Args:
          jiant_model (JiantModel): jiant model (encoder and task models are core components).
          weights_dict (Dict): model weights.
          load_mode: TODO
  
      Returns:
          TODO: return behavior is not consistent between load_mode options, clarify as needed here.
  
      """
      if load_mode == "from_transformers":
          return load_encoder_from_transformers_weights(
              encoder=jiant_model.encoder,
              weights_dict=weights_dict,
          )
      elif load_mode == "from_transformers_with_mlm":
          remainder = load_encoder_from_transformers_weights(
              encoder=jiant_model.encoder,
              weights_dict=weights_dict,
              return_remainder=True,
          )
          load_lm_heads_from_transformers_weights(
              jiant_model=jiant_model,
              weights_dict=remainder,
          )
          return
      elif load_mode == "all":
          jiant_model.load_state_dict(weights_dict)
      elif load_mode == "encoder_only":
          return load_encoder_only(
              jiant_model=jiant_model, weights_dict=weights_dict
          )
      elif load_mode == "partial_weights":
          return load_partial_heads(
              jiant_model=jiant_model,
              weights_dict=weights_dict,
              allow_missing_head_weights=True,
          )
      elif load_mode == "partial_heads":
          return load_partial_heads(
              jiant_model=jiant_model,
              weights_dict=weights_dict,
              allow_missing_head_model=True,
          )
      elif load_mode == "partial":
          return load_partial_heads(
              jiant_model=jiant_model,
              weights_dict=weights_dict,
              allow_missing_head_weights=True,
              allow_missing_head_model=True,
          )
      else:
          raise KeyError(load_mode)
  
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 3 for calling a global function with example usage: delegate_load(jiant_model, weights_dict, load_mode) and returns: load_encoder_from_transformers_weights, load_encoder_only, load_partial_heads, load_partial_heads, load_partial_heads