code: def xavier_normal_(
      tensor: torch.Tensor, gain: float = 1.0
  ) -> torch.Tensor:
      r"""Initialize weights of the tensor similarly to Glorot/Xavier initialization.
  
      Proceed as if it was a linear layer with `fan_in` of zero, `fan_out` of `prod(tensor.shape[1:])` and Xavier Normal
      initialization is used, i.e. fill the weight of input `tensor` with values
      sampled from :math:`\mathcal{N}(0, \text{std}^2)` where
  
      .. math::
          \text{std} = \text{gain} \times \sqrt{\frac{2}{\text{fan_out}}}
  
      Example usage:
  
      >>> import torch, pykeen.nn.init
      >>> w = torch.empty(3, 5)
      >>> pykeen.nn.init.xavier_normal_(w, gain=torch.nn.init.calculate_gain("relu"))
  
      .. seealso::
          :func:`torch.nn.init.xavier_normal_`
  
      :param tensor:
          a tensor to initialize
      :param gain:
          an optional scaling factor, defaults to 1.0.
  
      :return:
          tensor with weights by this initializer.
      """
      fan_out = np.prod(tensor.shape[1:])
      std = gain * math.sqrt(2.0 / float(fan_out))
      return torch.nn.init.normal_(tensor, mean=0.0, std=std)
  
imports: import functools
  import logging
  import math
  from typing import Any, Optional, Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.init
  import torch_ppr.utils
  from class_resolver import FunctionResolver, Hint, HintOrType, OptionalKwargs
  from more_itertools import last
  from torch.nn import functional
  from .text import TextEncoder, text_encoder_resolver
  from .utils import iter_matrix_power, safe_diagonal
  from ..triples import CoreTriplesFactory, TriplesFactory
  from ..typing import Initializer, MappedTriples, OneOrSequence
  from ..utils import compose, get_edge_index, iter_weisfeiler_lehman, upgrade_to_sequence
label_desc: Use image node_id 2 for calling a global function with example usage: xavier_normal_(tensor, gain) and returns: torch