torch.nn.utils.parametrizations.spectral_norm
torch.nn.utils.parametrizations.spectral_norm(module, name='weight', n_power_iterations=1, eps=1e-12, dim=None)
Applies spectral normalization to a parameter in the given module.
  \mathbf{W}_{SN} = \dfrac{\mathbf{W}}{\sigma(\mathbf{W})},
  \sigma(\mathbf{W}) = \max_{\mathbf{h}: \mathbf{h} \ne 0}
  \dfrac{\|\mathbf{W} \mathbf{h}\|_2}{\|\mathbf{h}\|_2}

When applied on a vector, it simplifies to
  \mathbf{x}_{SN} = \dfrac{\mathbf{x}}{\|\mathbf{x}\|_2}

Spectral normalization stabilizes the training of discriminators
   (critics) in Generative Adversarial Networks (GANs) by reducing the
   Lipschitz constant of the model. \sigma is approximated performing
   one iteration of the power method every time the weight is
   accessed. If the dimension of the weight tensor is greater than 2,
   it is reshaped to 2D in power iteration method to get spectral
   norm.