code: def init_W(config, W_left=None, W_right=None, W=None):
      """
      Initialize the weights for the compacter module or the shared parameters
      """
      if config["factorized_phm_W"]:
          W_left = W_left
          W_right = W_right
      else:
          W = W
      if config["hypercomplex_nonlinearity"]:
          if config["factorized_phm_W"]:
              for i in range(config["phm_dim"]):
                  W_left.data[i] = nn.init.xavier_normal_(
                      W_left.data[i]
                  )
                  W_right.data[i] = nn.init.xavier_normal_(
                      W_right.data[i]
                  )
          else:
              for i in range(config["phm_dim"]):
                  W.data[i] = nn.init.xavier_normal_(W.data[i])
      elif config["hypercomplex_nonlinearity"] == "glorot-uniform":
          if config["factorized_phm_W"]:
              for i in range(config["phm_dim"]):
                  W_left.data[i] = nn.init.xavier_uniform_(
                      W_left.data[i]
                  )
                  W_right.data[i] = nn.init.xavier_uniform_(
                      W_right.data[i]
                  )
          else:
              for i in range(config["phm_dim"]):
                  W.data[i] = nn.init.xavier_uniform_(W.data[i])
      elif config["hypercomplex_nonlinearity"] == "normal":
          if config["factorized_phm_W"]:
              for i in range(config["phm_dim"]):
                  W_left.data[i].normal_(
                      mean=0, std=config["phm_init_range"]
                  )
                  W_right.data[i].normal_(
                      mean=0, std=config["phm_init_range"]
                  )
          else:
              for i in range(config["phm_dim"]):
                  W.data[i].normal_(
                      mean=0, std=config["phm_init_range"]
                  )
      else:
          raise ValueError
  
imports: import math
  import torch
  from torch import nn
  from transformers.activations import get_activation
  from ..configuration import AdapterFusionConfig, BnConfig
  from ..context import ForwardContext
label_desc: Use image node_id 4 for calling a global function with example usage: init_W(config, W_left, W_right, W) without return types