def get_neighbors(self, items):
    "Get neighbors and corresponding relations for each entity in items from adj_entity and adj_relation.\n\n        Args:\n            items(torch.LongTensor): The input tensor that contains item's id, shape: [batch_size, ]\n\n        Returns:\n            tuple:\n                - entities(list): Entities is a list of i-iter (i = 0, 1, ..., n_iter) neighbors for the batch of items.\n                  dimensions of entities: {[batch_size, 1],\n                  [batch_size, n_neighbor],\n                  [batch_size, n_neighbor^2],\n                  ...,\n                  [batch_size, n_neighbor^n_iter]}\n                - relations(list): Relations is a list of i-iter (i = 0, 1, ..., n_iter) corresponding relations for\n                  entities. Relations have the same shape as entities.\n        "
    items = torch.unsqueeze(items, dim=1)
    entities = [items]
    relations = []
    for i in range(self.n_iter):
        index = torch.flatten(entities[i])
        neighbor_entities = torch.reshape(torch.index_select(self.adj_entity, 0, index), (self.batch_size, (- 1)))
        neighbor_relations = torch.reshape(torch.index_select(self.adj_relation, 0, index), (self.batch_size, (- 1)))
        entities.append(neighbor_entities)
        relations.append(neighbor_relations)
    return (entities, relations)
Get neighbors and corresponding relations for each entity in items from adj_entity and adj_relation.

Args:
    items(torch.LongTensor): The input tensor that contains item's id, shape: [batch_size, ]

Returns:
    tuple:
        - 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.
def get_neighbors(self, items):
    "Get neighbors and corresponding relations for each entity in items from adj_entity and adj_relation.\n\n        Args:\n            items(torch.LongTensor): The input tensor that contains item's id, shape: [batch_size, ]\n\n        Returns:\n            tuple:\n                - entities(list): Entities is a list of i-iter (i = 0, 1, ..., n_iter) neighbors for the batch of items.\n                  dimensions of entities: {[batch_size, 1],\n                  [batch_size, n_neighbor],\n                  [batch_size, n_neighbor^2],\n                  ...,\n                  [batch_size, n_neighbor^n_iter]}\n                - relations(list): Relations is a list of i-iter (i = 0, 1, ..., n_iter) corresponding relations for\n                  entities. Relations have the same shape as entities.\n        "
    items = torch.unsqueeze(items, dim=1)
    entities = [items]
    relations = []
    for i in range(self.n_iter):
        index = torch.flatten(entities[i])
        neighbor_entities = torch.reshape(torch.index_select(self.adj_entity, 0, index), (self.batch_size, (- 1)))
        neighbor_relations = torch.reshape(torch.index_select(self.adj_relation, 0, index), (self.batch_size, (- 1)))
        entities.append(neighbor_entities)
        relations.append(neighbor_relations)
    return (entities, relations)