code: def test_initializers(self):
      as_np_f64 = lambda t: np.array(t, dtype=np.float64)
      # This just makes sure we can call the initializers in accordance to the
      # API and get the right shapes and dtypes out.
      inits = [
          initializers.Constant(42.0),
          initializers.Constant(as_np_f64(42.0)),
          initializers.RandomNormal(),
          initializers.RandomNormal(2.0),
          initializers.RandomNormal(as_np_f64(2.0)),
          initializers.RandomUniform(),
          initializers.RandomUniform(3.0),
          initializers.RandomUniform(as_np_f64(3.0)),
          initializers.VarianceScaling(),
          initializers.VarianceScaling(2.0),
          initializers.VarianceScaling(as_np_f64(2.0)),
          initializers.VarianceScaling(2.0, mode="fan_in"),
          initializers.VarianceScaling(
              as_np_f64(2.0), mode="fan_in", fan_in_axes=[0]
          ),
          initializers.VarianceScaling(
              2.0, mode="fan_in", fan_in_axes=[0]
          ),
          initializers.VarianceScaling(as_np_f64(2.0), mode="fan_in"),
          initializers.VarianceScaling(2.0, mode="fan_out"),
          initializers.VarianceScaling(as_np_f64(2.0), mode="fan_out"),
          initializers.VarianceScaling(2.0, mode="fan_avg"),
          initializers.VarianceScaling(as_np_f64(2.0), mode="fan_avg"),
          initializers.VarianceScaling(
              2.0, distribution="truncated_normal"
          ),
          initializers.VarianceScaling(
              as_np_f64(2.0), distribution="truncated_normal"
          ),
          initializers.VarianceScaling(2.0, distribution="normal"),
          initializers.VarianceScaling(
              as_np_f64(2.0), distribution="normal"
          ),
          initializers.VarianceScaling(2.0, distribution="uniform"),
          initializers.VarianceScaling(
              as_np_f64(2.0), distribution="uniform"
          ),
          initializers.UniformScaling(),
          initializers.UniformScaling(2.0),
          initializers.UniformScaling(as_np_f64(2.0)),
          initializers.TruncatedNormal(),
          initializers.Orthogonal(),
          initializers.Identity(),
          initializers.Identity(as_np_f64(2.0)),
          # Users are supposed to be able to use these.
          jnp.zeros,
          jnp.ones,
      ]
  
      # TODO(ibab): Test other shapes as well.
      shape = (20, 42)
  
      dtype = jnp.float32
      for init in inits:
          generated = init(shape, dtype)
          self.assertEqual(generated.shape, shape)
          self.assertEqual(generated.dtype, dtype)
  
imports: import itertools
  from absl.testing import absltest
  from absl.testing import parameterized
  from haiku._src import initializers
  from haiku._src import test_utils
  import jax
  from jax import config
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 for calling the InitializersTest obj's underlying member method code with example usage: obj.test_initializers() without return types