code: def __init__(
      self,
      ent_tot,
      rel_tot,
      dim=100,
      p_norm=1,
      norm_flag=True,
      margin=None,
      epsilon=None,
  ):
      super(TransE, self).__init__(ent_tot, rel_tot)
  
      self.dim = dim
      self.margin = margin
      self.epsilon = epsilon
      self.norm_flag = norm_flag
      self.p_norm = p_norm
  
      self.ent_embeddings = nn.Embedding(self.ent_tot, self.dim)
      self.rel_embeddings = nn.Embedding(self.rel_tot, self.dim)
  
      if margin == None or epsilon == None:
          nn.init.xavier_uniform_(self.ent_embeddings.weight.data)
          nn.init.xavier_uniform_(self.rel_embeddings.weight.data)
      else:
          self.embedding_range = nn.Parameter(
              torch.Tensor([(self.margin + self.epsilon) / self.dim]),
              requires_grad=False,
          )
          nn.init.uniform_(
              tensor=self.ent_embeddings.weight.data,
              a=-self.embedding_range.item(),
              b=self.embedding_range.item(),
          )
          nn.init.uniform_(
              tensor=self.rel_embeddings.weight.data,
              a=-self.embedding_range.item(),
              b=self.embedding_range.item(),
          )
  
      if margin != None:
          self.margin = nn.Parameter(torch.Tensor([margin]))
          self.margin.requires_grad = False
          self.margin_flag = True
      else:
          self.margin_flag = False
  
file_path: OpenKE/openke/module/model/TransE.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from .Model import Model
label_desc: Use image node_id 1 to create a new TransE object from inherited base classes: Model with example: obj = TransE(ent_tot, rel_tot, dim, p_norm, norm_flag, margin, epsilon)