code: def _sample_distribution(shape, var, distribution, seed, dtype):
      """Samples from specified distribution (by appropriately scaling `var` arg."""
      distribution = str(distribution).lower()
      if distribution == "truncated_normal":
          # constant taken from scipy.stats.truncnorm.std(a=-2, b=2, loc=0., scale=1.)
          stddev = prefer_static.sqrt(var) / 0.87962566103423978
          return tf.random.stateless_truncated_normal(
              shape,
              mean=0.0,
              stddev=stddev,
              dtype=dtype,
              seed=samplers.sanitize_seed(seed),
          )
      elif distribution == "uniform":
          limit = prefer_static.sqrt(3.0 * var)
          return samplers.uniform(
              shape, minval=-limit, maxval=limit, dtype=dtype, seed=seed
          )
      elif distribution == "untruncated_normal":
          stddev = prefer_static.sqrt(var)
          return samplers.normal(
              shape, mean=0.0, stddev=stddev, dtype=dtype, seed=seed
          )
      raise ValueError(
          'Unrecognized distribution: "{}".'.format(distribution)
      )
  
file_path: probability/tensorflow_probability/python/experimental/nn/initializers/initializers.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
label_desc: Use image node_id 8 for calling a global function with example usage: _sample_distribution(shape, var, distribution, seed, dtype) and returns: tf, samplers, samplers