class_docstr: KGNN-LS is a knowledge-based recommendation model.
  KGNN-LS transforms the knowledge graph into a user-specific weighted graph and then apply a graph neural network to
  compute personalized item embeddings. To provide better inductive bias, KGNN-LS relies on label smoothness
  assumption, which posits that adjacent items in the knowledge graph are likely to have similar user relevance
  labels/scores. Label smoothness provides regularization over the edge weights and it is equivalent  to a label
  propagation scheme on a graph.
docstr: For each item, aggregate the entity representation and its neighborhood representation into a single vector.
  
  Args:
      user_embeddings(torch.FloatTensor): The embeddings of users, shape: [batch_size, embedding_size]
      entities(list): entities is a list of i-iter (i = 0, 1, ..., n_iter) neighbors for the batch of items.
                      dimensions of entities: {[batch_size, 1],
                      [batch_size, n_neighbor],
                      [batch_size, n_neighbor^2],
                      ...,
                      [batch_size, n_neighbor^n_iter]}
      relations(list): relations is a list of i-iter (i = 0, 1, ..., n_iter) corresponding relations for entities.
                       relations have the same shape as entities.
  
  Returns:
      item_embeddings(torch.FloatTensor): The embeddings of items, shape: [batch_size, embedding_size]
docstr_tok: ["For","each","item",",","aggregate","the","entity","representation","and","its","neighborhood","representation","into","a","single","vector",".","Args",":","user_embeddings","(","torch.FloatTensor",")",":","The","embeddings","of","users",",","shape",":","[","batch_size",",","embedding_size","]","entities","(","list",")",":","entities","is","a","list","of","i-iter","(","i","=","0",",","1",",","...",",","n_iter",")","neighbors","for","the","batch","of","items",".","dimensions","of","entities",":","{","[","batch_size",",","1","]",",","[","batch_size",",","n_neighbor","]",",","[","batch_size",",","n_neighbor^2","]",",","...",",","[","batch_size",",","n_neighbor^n_iter","]","}","relations","(","list",")",":","relations","is","a","list","of","i-iter","(","i","=","0",",","1",",","...",",","n_iter",")","corresponding","relations","for","entities",".","relations","have","the","same","shape","as","entities",".","Returns",":","item_embeddings","(","torch.FloatTensor",")",":","The","embeddings","of","items",",","shape",":","[","batch_size",",","embedding_size","]"]
code: def aggregate(self, user_embeddings, entities, relations):
      r"""For each item, aggregate the entity representation and its neighborhood representation into a single vector.
  
      Args:
          user_embeddings(torch.FloatTensor): The embeddings of users, shape: [batch_size, embedding_size]
          entities(list): entities is a list of i-iter (i = 0, 1, ..., n_iter) neighbors for the batch of items.
                          dimensions of entities: {[batch_size, 1],
                          [batch_size, n_neighbor],
                          [batch_size, n_neighbor^2],
                          ...,
                          [batch_size, n_neighbor^n_iter]}
          relations(list): relations is a list of i-iter (i = 0, 1, ..., n_iter) corresponding relations for entities.
                           relations have the same shape as entities.
  
      Returns:
          item_embeddings(torch.FloatTensor): The embeddings of items, shape: [batch_size, embedding_size]
  
      """
      entity_vectors = [self.entity_embedding(i) for i in entities]
      relation_vectors = [self.relation_embedding(i) for i in relations]
  
      for i in range(self.n_iter):
          entity_vectors_next_iter = []
          for hop in range(self.n_iter - i):
              shape = (
                  self.batch_size,
                  -1,
                  self.neighbor_sample_size,
                  self.embedding_size,
              )
              self_vectors = entity_vectors[hop]
              neighbor_vectors = entity_vectors[hop + 1].reshape(shape)
              neighbor_relations = relation_vectors[hop].reshape(shape)
  
              # mix_neighbor_vectors
              user_embeddings = user_embeddings.reshape(
                  self.batch_size, 1, 1, self.embedding_size
              )  # [batch_size, 1, 1, dim]
              user_relation_scores = torch.mean(
                  user_embeddings * neighbor_relations, dim=-1
              )  # [batch_size, -1, n_neighbor]
              user_relation_scores_normalized = torch.unsqueeze(
                  self.softmax(user_relation_scores), dim=-1
              )  # [batch_size, -1, n_neighbor, 1]
              neighbors_agg = torch.mean(
                  user_relation_scores_normalized * neighbor_vectors,
                  dim=2,
              )  # [batch_size, -1, dim]
  
              if self.aggregator_class == "sum":
                  output = (self_vectors + neighbors_agg).reshape(
                      -1, self.embedding_size
                  )  # [-1, dim]
              elif self.aggregator_class == "neighbor":
                  output = neighbors_agg.reshape(
                      -1, self.embedding_size
                  )  # [-1, dim]
              elif self.aggregator_class == "concat":
                  # [batch_size, -1, dim * 2]
                  output = torch.cat(
                      [self_vectors, neighbors_agg], dim=-1
                  )
                  output = output.reshape(
                      -1, self.embedding_size * 2
                  )  # [-1, dim * 2]
              else:
                  raise Exception(
                      "Unknown aggregator: " + self.aggregator_class
                  )
  
              output = self.linear_layers[i](output)
              # [batch_size, -1, dim]
              output = output.reshape(
                  self.batch_size, -1, self.embedding_size
              )
  
              if i == self.n_iter - 1:
                  vector = self.Tanh(output)
              else:
                  vector = self.ReLU(output)
  
              entity_vectors_next_iter.append(vector)
          entity_vectors = entity_vectors_next_iter
  
      res = entity_vectors[0].reshape(
          self.batch_size, self.embedding_size
      )
      return res
  
imports: import random
  import numpy
  import torch
  import torch.nn
  from recbole.model.abstract_recommender import KnowledgeRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.loss import EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 6 for calling the KGNNLS obj's underlying member method code with example usage: obj.aggregate(user_embeddings, entities, relations) and returns: res