code: def xavier_init_layer(
      in_size,
      out_size=None,
      spec_norm=True,
      layer_type=nn.Linear,
      **kwargs,
  ):
      "Create a layer with spectral norm, xavier uniform init and zero bias"
      if out_size is None:
          out_size = in_size
  
      layer = layer_type(in_size, out_size, **kwargs)
      if spec_norm:
          layer = spectral_norm(layer)
  
      # Perform initialization
      nn.init.xavier_uniform_(layer.weight, gain=1.0)
      nn.init.zeros_(layer.bias)
  
      return layer
  
file_path: speechbrain/speechbrain/lobes/models/MetricGAN_U.py
imports: import torch
  import speechbrain
  from torch import nn
  from torch.nn.utils import spectral_norm
label_desc: Use image node_id 1 for calling a global function with example usage: xavier_init_layer(in_size, out_size, spec_norm, layer_type) and returns: layer