class_docstr: A regularizer for the soft orthogonality constraints from [wang2014]_.
class_docstr_tok: ["A","regularizer","for","the","soft","orthogonality","constraints","from","[","wang2014","]","_","."]
code: def update(self, *tensors: torch.FloatTensor) -> None:  # noqa: D102
      if len(tensors) != 2:
          raise ValueError("Expects exactly two tensors")
      if self.apply_only_once and self.updated:
          return
      # orthogonality soft constraint: cosine similarity at most epsilon
      self.regularization_term = self.regularization_term + (
          functional.cosine_similarity(*tensors, dim=-1)
          .pow(2)
          .subtract(self.epsilon)
          .relu()
          .sum()
      )
      self.updated = True
  
imports: from __future__ import annotations
  import warnings
  from abc import ABC, abstractmethod
  from typing import Any, ClassVar, Iterable, Mapping, Optional
  import torch
  from class_resolver import ClassResolver, normalize_string
  from torch import nn
  from torch.nn import functional
  from .utils import lp_norm, powersum_norm
label_desc: Use image node_id 3 for calling the OrthogonalityRegularizer obj's underlying member method code with example usage: obj.update() without return types