class_docstr: Initializer which adapts its scale to the shape of the initialized array.
  
  The initializer first computes the scaling factor ``s = scale / n``, where n
  is:
  
    - Number of input units in the weight tensor, if ``mode = fan_in``.
    - Number of output units, if ``mode = fan_out``.
    - Average of the numbers of input and output units, if ``mode = fan_avg``.
  
  Then, with ``distribution="truncated_normal"`` or ``"normal"``,
  samples are drawn from a distribution with a mean of zero and a standard
  deviation (after truncation, if used) ``stddev = sqrt(s)``.
  
  With ``distribution=uniform``, samples are drawn from a uniform distribution
  within ``[-limit, limit]``, with ``limit = sqrt(3 * s)``.
  
  The variance scaling initializer can be configured to generate other standard
  initializers using the scale, mode and distribution arguments. Here are some
  example configurations:
  
  ==============  ==============================================================
  Name            Parameters
  ==============  ==============================================================
  glorot_uniform  VarianceScaling(1.0, "fan_avg", "uniform")
  glorot_normal   VarianceScaling(1.0, "fan_avg", "truncated_normal")
  lecun_uniform   VarianceScaling(1.0, "fan_in",  "uniform")
  lecun_normal    VarianceScaling(1.0, "fan_in",  "truncated_normal")
  he_uniform      VarianceScaling(2.0, "fan_in",  "uniform")
  he_normal       VarianceScaling(2.0, "fan_in",  "truncated_normal")
  ==============  ==============================================================
docstr: Constructs the :class:`VarianceScaling` initializer.
  
  Args:
    scale: Scale to multiply the variance by.
    mode: One of ``fan_in``, ``fan_out``, ``fan_avg``
    distribution: Random distribution to use. One of ``truncated_normal``,
      ``normal`` or ``uniform``.
    fan_in_axes: Optional sequence of int specifying which axes of the shape
      are part of the fan-in. If none provided, then the weight is assumed
      to be like a convolution kernel, where all leading dimensions are part
      of the fan-in, and only the trailing dimension is part of the fan-out.
      Useful if instantiating multi-headed attention weights.
docstr_tok: ["Constructs","the",":","class",":","`","VarianceScaling","`","initializer",".","Args",":","scale",":","Scale","to","multiply","the","variance","by",".","mode",":","One","of","``","fan_in","``",",","``","fan_out","``",",","``","fan_avg","``","distribution",":","Random","distribution","to","use",".","One","of","``","truncated_normal","``",",","``","normal","``","or","``","uniform","``",".","fan_in_axes",":","Optional","sequence","of","int","specifying","which","axes","of","the","shape","are","part","of","the","fan-in",".","If","none","provided",",","then","the","weight","is","assumed","to","be","like","a","convolution","kernel",",","where","all","leading","dimensions","are","part","of","the","fan-in",",","and","only","the","trailing","dimension","is","part","of","the","fan-out",".","Useful","if","instantiating","multi-headed","attention","weights","."]
code: def __init__(
      self,
      scale=1.0,
      mode="fan_in",
      distribution="truncated_normal",
      fan_in_axes=None,
  ):
      """Constructs the :class:`VarianceScaling` initializer.
  
      Args:
        scale: Scale to multiply the variance by.
        mode: One of ``fan_in``, ``fan_out``, ``fan_avg``
        distribution: Random distribution to use. One of ``truncated_normal``,
          ``normal`` or ``uniform``.
        fan_in_axes: Optional sequence of int specifying which axes of the shape
          are part of the fan-in. If none provided, then the weight is assumed
          to be like a convolution kernel, where all leading dimensions are part
          of the fan-in, and only the trailing dimension is part of the fan-out.
          Useful if instantiating multi-headed attention weights.
      """
      if scale < 0.0:
          raise ValueError("`scale` must be a positive float.")
      if mode not in {"fan_in", "fan_out", "fan_avg"}:
          raise ValueError("Invalid `mode` argument:", mode)
      distribution = distribution.lower()
      if distribution not in {"normal", "truncated_normal", "uniform"}:
          raise ValueError(
              "Invalid `distribution` argument:", distribution
          )
      self.scale = scale
      self.mode = mode
      self.distribution = distribution
      self.fan_in_axes = fan_in_axes
  
imports: from collections.abc import Sequence
  from typing import Any, Union
  from haiku._src import base
  from haiku._src.typing import Initializer
  import jax
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 to create a new VarianceScaling object from inherited base classes: hk.initializers with example: obj = VarianceScaling(scale, mode, distribution, fan_in_axes)