class_docstr: Regularizer that encourages input vectors to be orthogonal to each other.
  
  It can be applied to either the rows of a matrix (`mode="rows"`) or its
  columns (`mode="columns"`). When applied to a `Dense` kernel of shape
  `(input_dim, units)`, rows mode will seek to make the feature vectors
  (i.e. the basis of the output space) orthogonal to each other.
  
  Arguments:
      factor: Float. The regularization factor. The regularization penalty
          will be proportional to `factor` times the mean of the dot products
          between the L2-normalized rows (if `mode="rows"`, or columns if
          `mode="columns"`) of the inputs, excluding the product of each
          row/column with itself.  Defaults to `0.01`.
      mode: String, one of `{"rows", "columns"}`. Defaults to `"rows"`. In
          rows mode, the regularization effect seeks to make the rows of the
          input orthogonal to each other. In columns mode, it seeks to make
          the columns of the input orthogonal to each other.
  
  Example:
  
  >>> regularizer = OrthogonalRegularizer(factor=0.01)
  >>> layer = Dense(units=4, kernel_regularizer=regularizer)
code: def __call__(self, inputs):
      if len(inputs.shape) != 2:
          raise ValueError(
              "Inputs to OrthogonalRegularizer must have rank 2. Received: "
              f"inputs.shape={inputs.shape}"
          )
      if self.mode == "rows":
          inputs = normalize(inputs, axis=1)
          product = ops.matmul(inputs, ops.transpose(inputs))
          size = inputs.shape[0]
      else:
          inputs = normalize(inputs, axis=0)
          product = ops.matmul(ops.transpose(inputs), inputs)
          size = inputs.shape[1]
      product_no_diagonal = product * (
          1.0 - ops.eye(size, dtype=inputs.dtype)
      )
      num_pairs = size * (size - 1.0) / 2.0
      return (
          self.factor
          * 0.5
          * ops.sum(ops.absolute(product_no_diagonal))
          / num_pairs
      )
  
imports: import math
  from keras import ops
  from keras.api_export import keras_export
  from keras.utils.numerical_utils import normalize
label_desc: Use image node_id 2 for calling the OrthogonalRegularizer obj's underlying member method code with example usage: obj.__call__(inputs) and returns: unknown