code: def test_spectral_norm_3d_tensor(self, error_on_non_matrix):
      class Foo(nn.Module):
          @nn.compact
          def __call__(self, x, train):
              x = nn.SpectralNorm(
                  nn.DenseGeneral((3, 4), use_bias=False),
                  error_on_non_matrix=error_on_non_matrix,
              )(x, update_stats=train)
              return x
  
      x = jnp.ones((1, 2))
      model_cls = Foo()
  
      if error_on_non_matrix:
          with self.assertRaisesRegex(
              ValueError, "Input is 3D but error_on_non_matrix is True"
          ):
              _ = model_cls.init(random.PRNGKey(0), x, train=False)
      else:
          _ = model_cls.init(random.PRNGKey(0), x, train=False)
  
imports: import copy
  import functools
  from typing import Any
  import jax
  import jax.numpy
  import numpy
  import optax
  from absl.testing import absltest, parameterized
  from jax import random
  from flax import ids
  from flax import linen
  from flax.linen import fp8_ops
  from flax.training import train_state
label_desc: Use image node_id 16 for calling the NormalizationTest obj's underlying member method code with example usage: obj.test_spectral_norm_3d_tensor(error_on_non_matrix) and returns: x