code: def _set_state_dict_into_text_encoder(
      lora_state_dict: Dict[str, torch.Tensor],
      prefix: str,
      text_encoder: torch.nn.Module,
  ):
      """
      Sets the `lora_state_dict` into `text_encoder` coming from `transformers`.
  
      Args:
          lora_state_dict: The state dictionary to be set.
          prefix: String identifier to retrieve the portion of the state dict that belongs to `text_encoder`.
          text_encoder: Where the `lora_state_dict` is to be set.
      """
  
      text_encoder_state_dict = {
          f'{k.replace(prefix, "")}': v
          for k, v in lora_state_dict.items()
          if k.startswith(prefix)
      }
      text_encoder_state_dict = convert_state_dict_to_peft(
          convert_state_dict_to_diffusers(text_encoder_state_dict)
      )
      set_peft_model_state_dict(
          text_encoder, text_encoder_state_dict, adapter_name="default"
      )
  
imports: import contextlib
  import copy
  import random
  from typing import Any, Dict, Iterable, List, Optional, Union
  import numpy
  import torch
  from torchvision import transforms
  from .models import UNet2DConditionModel
  from .utils import convert_state_dict_to_diffusers, convert_state_dict_to_peft, deprecate, is_peft_available, is_transformers_available
label_desc: Use image node_id 6 for calling a global function with example usage: _set_state_dict_into_text_encoder(lora_state_dict, prefix, text_encoder) without return types