code: def assign_network_names_to_compvis_modules(sd_model):
      network_layer_mapping = {}
  
      if shared.sd_model.is_sdxl:
          for i, embedder in enumerate(
              shared.sd_model.conditioner.embedders
          ):
              if not hasattr(embedder, "wrapped"):
                  continue
  
              for name, module in embedder.wrapped.named_modules():
                  network_name = f'{i}_{name.replace(".", "_")}'
                  network_layer_mapping[network_name] = module
                  module.network_layer_name = network_name
      else:
          for (
              name,
              module,
          ) in shared.sd_model.cond_stage_model.wrapped.named_modules():
              network_name = name.replace(".", "_")
              network_layer_mapping[network_name] = module
              module.network_layer_name = network_name
  
      for name, module in shared.sd_model.model.named_modules():
          network_name = name.replace(".", "_")
          network_layer_mapping[network_name] = module
          module.network_layer_name = network_name
  
      sd_model.network_layer_mapping = network_layer_mapping
  
imports: import logging
  import os
  import re
  import lora_patches
  import network
  import network_lora
  import network_glora
  import network_hada
  import network_ia3
  import network_lokr
  import network_full
  import network_norm
  import network_oft
  import torch
  from typing import Union
  from modules import shared, devices, sd_models, errors, scripts, sd_hijack
  import modules.textual_inversion.textual_inversion
  from lora_logger import logger
label_desc: Use image node_id 2 for calling a global function with example usage: assign_network_names_to_compvis_modules(sd_model) without return types