class_docstr: Initializer capable of adapting its scale to the shape of weights tensors.
  
  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(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``.
  
  Note that for transposed convolution the mode selected should be reversed. For
  number of input units use ``fan_out`` and for number of output units
  ``fan_in``.
  
  With ``distribution=uniform``, samples are drawn from a uniform distribution
  within ``[-limit, limit]``, with ``limit = sqrt(3 * scale / n)``.
  
  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  scale=1.0, mode=``fan_avg``, distribution=``uniform``
  glorot_normal   scale=1.0, mode=``fan_avg``, distribution=``truncated_normal``
  lecun_uniform   scale=1.0, mode=``fan_in``,  distribution=``uniform``
  lecun_normal    scale=1.0, mode=``fan_in``,  distribution=``truncated_normal``
  he_uniform      scale=2.0, mode=``fan_in``,  distribution=``uniform``
  he_normal       scale=2.0, mode=``fan_in``,  distribution=``truncated_normal``
  ==============  ==============================================================
class_docstr_tok: ["Initializer","capable","of","adapting","its","scale","to","the","shape","of","weights","tensors",".","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","(","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","``",".","Note","that","for","transposed","convolution","the","mode","selected","should","be","reversed",".","For","number","of","input","units","use","``","fan_out","``","and","for","number","of","output","units","``","fan_in","``",".","With","``","distribution=uniform","``",",","samples","are","drawn","from","a","uniform","distribution","within","``","[","-limit",",","limit","]","``",",","with","``","limit","=","sqrt","(","3","*","scale","\/","n",")","``",".","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","scale=1.0",",","mode=","``","fan_avg","``",",","distribution=","``","uniform","``","glorot_normal","scale=1.0",",","mode=","``","fan_avg","``",",","distribution=","``","truncated_normal","``","lecun_uniform","scale=1.0",",","mode=","``","fan_in","``",",","distribution=","``","uniform","``","lecun_normal","scale=1.0",",","mode=","``","fan_in","``",",","distribution=","``","truncated_normal","``","he_uniform","scale=2.0",",","mode=","``","fan_in","``",",","distribution=","``","uniform","``","he_normal","scale=2.0",",","mode=","``","fan_in","``",",","distribution=","``","truncated_normal","``","==============","=============================================================="]
docstr: Constructs a variance scaling initalizer.
  
  Args:
    scale: Scaling factor (positive ``float``).
    mode: One of ``fan_in``, ``fan_out``, ``fan_avg``.
    distribution: Random distribution to use. One of ``truncated_normal``,
      ``untruncated_normal`` and  ``uniform``.
    seed: ``int``, the seed used in the generation of random numbers.
  
  Raises:
    ValueError: In case of an invalid value for the ``scale``, ``mode`` or
      ``distribution`` arguments.
docstr_tok: ["Constructs","a","variance","scaling","initalizer",".","Args",":","scale",":","Scaling","factor","(","positive","``","float","``",")",".","mode",":","One","of","``","fan_in","``",",","``","fan_out","``",",","``","fan_avg","``",".","distribution",":","Random","distribution","to","use",".","One","of","``","truncated_normal","``",",","``","untruncated_normal","``","and","``","uniform","``",".","seed",":","``","int","``",",","the","seed","used","in","the","generation","of","random","numbers",".","Raises",":","ValueError",":","In","case","of","an","invalid","value","for","the","``","scale","``",",","``","mode","``","or","``","distribution","``","arguments","."]
code: def __init__(
      self,
      scale: float = 1.0,
      mode: str = "fan_in",
      distribution: str = "truncated_normal",
      seed: Optional[int] = None,
  ):
      """Constructs a variance scaling initalizer.
  
      Args:
        scale: Scaling factor (positive ``float``).
        mode: One of ``fan_in``, ``fan_out``, ``fan_avg``.
        distribution: Random distribution to use. One of ``truncated_normal``,
          ``untruncated_normal`` and  ``uniform``.
        seed: ``int``, the seed used in the generation of random numbers.
  
      Raises:
        ValueError: In case of an invalid value for the ``scale``, ``mode`` or
          ``distribution`` arguments.
      """
      if scale <= 0.0:
          raise ValueError("`scale` must be 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 {"uniform", "truncated_normal", "normal"}:
          raise ValueError(
              "Invalid `distribution` argument:", distribution
          )
      self.scale = scale
      self.mode = mode
      self.distribution = distribution
      self.seed = seed
  
imports: import abc
  import collections
  from typing import Iterable, Mapping, Optional, Union
  import numpy
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 1 to create a new VarianceScaling object from inherited base classes: Initializer with example: obj = VarianceScaling(scale, mode, distribution, seed)