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","``","==============","=============================================================="]
code: def __call__(
      self, shape: types.ShapeLike, dtype: tf.DType
  ) -> tf.Tensor:
      dtype = _as_floating_dtype(dtype)
      scale = self.scale
      fan_in, fan_out = _compute_fans(shape)
      fan_in = tf.cast(fan_in, dtype)
      fan_out = tf.cast(fan_out, dtype)
      if self.mode == "fan_in":
          scale /= tf.maximum(1.0, fan_in)
      elif self.mode == "fan_out":
          scale /= tf.maximum(1.0, fan_out)
      else:
          scale /= tf.maximum(1.0, (fan_in + fan_out) / 2.0)
      if self.distribution == "truncated_normal":
          # constant from scipy.stats.truncnorm.std(a=-2, b=2, loc=0., scale=1.)
          distribution_stddev = 0.87962566103423978
          stddev = tf.sqrt(scale) / distribution_stddev
          return tf.random.truncated_normal(
              shape=shape,
              mean=0.0,
              stddev=stddev,
              dtype=dtype,
              seed=self.seed,
          )
      elif self.distribution == "normal":
          stddev = tf.sqrt(scale)
          return tf.random.normal(
              shape=shape,
              mean=0.0,
              stddev=stddev,
              dtype=dtype,
              seed=self.seed,
          )
      else:  # self.distribution == "uniform"
          limit = tf.sqrt(3.0 * scale)
          return tf.random.uniform(
              shape=shape,
              minval=-limit,
              maxval=limit,
              dtype=dtype,
              seed=self.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 2 for calling the VarianceScaling obj's underlying member method code with example usage: obj.__call__(shape, dtype) and returns: tf, tf, tf