code: def init_weights(m, mode: Optional[str] = "xavier_uniform"):
      if isinstance(m, MaskedConv1d):
          init_weights(m.conv, mode)
      if isinstance(m, (nn.Conv1d, nn.Linear)):
          if mode is not None:
              if mode == "xavier_uniform":
                  nn.init.xavier_uniform_(m.weight, gain=1.0)
              elif mode == "xavier_normal":
                  nn.init.xavier_normal_(m.weight, gain=1.0)
              elif mode == "kaiming_uniform":
                  nn.init.kaiming_uniform_(
                      m.weight, nonlinearity="relu"
                  )
              elif mode == "kaiming_normal":
                  nn.init.kaiming_normal_(m.weight, nonlinearity="relu")
              elif mode == "tds_uniform":
                  tds_uniform_(m.weight)
              elif mode == "tds_normal":
                  tds_normal_(m.weight)
              else:
                  raise ValueError(
                      "Unknown Initialization mode: {0}".format(mode)
                  )
      elif isinstance(m, nn.BatchNorm1d):
          if m.track_running_stats:
              m.running_mean.zero_()
              m.running_var.fill_(1)
              m.num_batches_tracked.zero_()
          if m.affine:
              nn.init.ones_(m.weight)
              nn.init.zeros_(m.bias)
  
imports: import math
  from typing import Callable, Iterable, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from torch.nn.init import _calculate_correct_fan
  from torch.nn.modules.utils import _single
  from nemo.collections.common.parts.utils import activation_registry
  from nemo.core.classes.mixins import AccessMixin
  from nemo.core.classes.mixins.adapter_mixins import AdapterModuleMixin
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling a global function with example usage: init_weights(m, mode) without return types