class_docstr: N3 regularizer described in https://arxiv.org/pdf/1806.07297.pdf
class_docstr_tok: ["N3","regularizer","described","in","https",":","\/\/arxiv.org\/pdf\/1806.07297.pdf"]
code: def forward(
      self,
      src_pos: FloatTensorType,
      dst_pos: FloatTensorType,
      operator: AbstractOperator,
  ) -> FloatTensorType:
      total = 0
      operator_params = operator.get_operator_params_for_reg()
      if operator_params is not None:
          operator_params = operator_params.to(src_pos.device)
          batch_size = len(src_pos)
          total += torch.sum(operator_params**3) * batch_size
      for x in (src_pos, dst_pos):
          total += torch.sum(operator.prepare_embs_for_reg(x) ** 3)
      total *= self.weight
      return total
  
file_path: PyTorch-BigGraph/torchbiggraph/regularizers.py
imports: from abc import ABC, abstractmethod
  from typing import Optional
  import torch
  import torchbiggraph.model
  from torchbiggraph.operators import AbstractDynamicOperator, AbstractOperator
  from torchbiggraph.plugin import PluginRegistry
  from torchbiggraph.types import FloatTensorType, LongTensorType
label_desc: Use image node_id 3 for calling the N3Regularizer obj's underlying member method code with example usage: obj.forward(src_pos, dst_pos, operator) and returns: total