code: def _inf_fan_adjust_xavier(scale, tensor):
      fan_out, fan_in = tensor.infshape[:2]
      # following are needed to accomodate SP models where all infshapes are finite so base_dims are Nones
      fan_out_base_dim = fan_out.base_dim or fan_out.dim
      fan_in_base_dim = fan_in.base_dim or fan_in.dim
      scale *= math.sqrt(
          (fan_out.dim + fan_in.dim)
          / (fan_out_base_dim + fan_in_base_dim)
      )
      if tensor.infshape.ninf() <= 1:
          # should have fixed scale
          pass
      elif tensor.infshape.ninf() == 2:
          # should scale like fanin
          assert fan_out.isinf() and fan_in.isinf()
          scale /= math.sqrt(fan_in.width_mult())
      else:
          raise NotImplementedError(
              "can only handle 2 inf dimensions currently"
          )
      return scale
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/mup/init.py
imports: import math
  import warnings
  import torch
  from torch.nn.init import _calculate_correct_fan, _calculate_fan_in_and_fan_out, _no_grad_fill_, _no_grad_normal_, _no_grad_uniform_, calculate_gain
label_desc: Use image node_id 6 for calling a global function with example usage: _inf_fan_adjust_xavier(scale, tensor) and returns: scale