code: def _get_neighbor_indices(worlds: List[WikiTablesWorld],
                                num_entities: int,
                                tensor: torch.Tensor) -> torch.LongTensor:
          
  
          num_neighbors = 0
          for world in worlds:
              for entity in world.table_graph.entities:
                  if len(world.table_graph.neighbors[entity]) > num_neighbors:
                      num_neighbors = len(world.table_graph.neighbors[entity])
  
          batch_neighbors = []
          for world in worlds:
              # Each batch instance has its own world, which has a corresponding table.
              entities = world.table_graph.entities
              entity2index = {entity: i for i, entity in enumerate(entities)}
              entity2neighbors = world.table_graph.neighbors
              neighbor_indexes = []
              for entity in entities:
                  entity_neighbors = [entity2index[n] for n in entity2neighbors[entity]]
                  # Pad with -1 instead of 0, since 0 represents a neighbor index.
                  padded = pad_sequence_to_length(entity_neighbors, num_neighbors, lambda: -1)
                  neighbor_indexes.append(padded)
              neighbor_indexes = pad_sequence_to_length(neighbor_indexes,
                                                        num_entities,
                                                        lambda: [-1] * num_neighbors)
              batch_neighbors.append(neighbor_indexes)
          return tensor.new_tensor(batch_neighbors, dtype=torch.long)
docs: This method returns the indices of each entity's neighbors. A tensor
          is accepted as a parameter for copying purposes.
  
          Parameters
          ----------
          worlds : ``List[WikiTablesWorld]``
          num_entities : ``int``
          tensor : ``torch.Tensor``
              Used for copying the constructed list onto the right device.
  
          Returns
          -------
          A ``torch.LongTensor`` with shape ``(batch_size, num_entities, num_neighbors)``. It is padded
          with -1 instead of 0, since 0 is a valid neighbor index.