code: def rep_ote(
      entity_feat,
      relation_feat,
      entity_neighbors,
      alpha,
      degree_w,
      r_emb=None,
      r_emb_mat=None,
      ote_size=20,
      indegrees=None,
      neighbor_norm=False,
      scale_norm=False,
  ):
      """For OTE and GC-OTE."""
      new_entity_feat = np.zeros(entity_feat.shape, dtype="float32")
      for i, efeat in enumerate(entity_feat):
          src_or_dst, r_type, direct = entity_neighbors[i]
          src_nfeat_value = entity_feat[src_or_dst]
          tmp_nfeat_list = np.zeros(
              (len(src_or_dst), entity_feat.shape[1])
          )
          for j, nfeat in enumerate(src_nfeat_value):
              if direct[j] == 1:
                  inputs_rel = r_emb[r_type[j]]
              elif direct[j] == -1:
                  inputs_rel = r_emb_mat[r_type[j]]
              else:
                  raise ValueError
              inputs_size = nfeat.shape
              inputs = nfeat.reshape(-1, 1, ote_size)
              rel = inputs_rel.reshape(-1, ote_size, ote_size + 1)
              scale = np.exp(rel[:, :, ote_size:])
              if scale_norm:
                  scale = scale / np.linalg.norm(
                      scale, axis=-1, keepdims=True
                  )
              rel_scale = rel[:, :, :ote_size] * scale
              outputs = np.matmul(inputs, rel_scale)
              outputs = outputs.reshape(inputs_size)
              tmp_nfeat_list[j] = outputs
  
          if len(tmp_nfeat_list) > 0:
              neigh_nfeat = tmp_nfeat_list
              if not neighbor_norm:
                  aggr_nfeat = np.mean(neigh_nfeat, axis=0)
              else:
                  src_indegrees = indegrees[src_or_dst]
                  src_norm = np.power(src_indegrees, degree_w)
                  src_norm = src_norm / np.sum(src_norm)
                  neigh_nfeat = neigh_nfeat * src_norm
                  aggr_nfeat = np.sum(neigh_nfeat, axis=0)
              new_nfeat = efeat * alpha + aggr_nfeat * (1 - alpha)
          else:
              new_nfeat = efeat
          new_entity_feat[i] = new_nfeat
      return new_entity_feat
  
file_path: PGL/apps/Graph4KG/examples/REP/rep.py
imports: import os
  import time
  import logging
  import argparse
  import numpy
  from tqdm import tqdm
  import pgl
  from ote_orth import OrthOTE
label_desc: Use image node_id 7 for calling a global function with example usage: rep_ote(entity_feat, relation_feat, entity_neighbors, alpha, degree_w, r_emb, r_emb_mat, ote_size, indegrees, neighbor_norm, scale_norm) and returns: new_entity_feat