Pytorch: Node2Vec: TypeError: tuple indices must be integers or slices, not tuple
I am trying to run Node2Vec from the torch_geometric.nn library. For reference, I am following this example.
While running the train() function I keep getting TypeError: tuple indices must be integers or slices, not tuple.
I am using torch version 1.6.0 with CUDA 10.1 and the latest versions of torch-scatter,torch-sparse,torch-cluster, torch-spline-conv and torch-geometric.
Here is the detailed error:
Part 1 of the Error
Part 2 of the Error
Thanks for any help.

The error was due to torch.ops.torch_cluster.random_walk returning a tuple instead of an array/tensor. I fixed it by using replacing the functions pos_sample and neg_sample in the torch_geometric.nn.Node2Vec with these.
def pos_sample(self, batch):
    batch = batch.repeat(self.walks_per_node)
    rowptr, col, _ = self.adj.csr()
    rw = random_walk(rowptr, col, batch, self.walk_length, self.p, self.q)
    if not isinstance(rw, torch.Tensor):
        rw = rw[0]

    walks = []
    num_walks_per_rw = 1 + self.walk_length + 1 - self.context_size
    for j in range(num_walks_per_rw):
        walks.append(rw[:, j:j + self.context_size])
    return torch.cat(walks, dim=0)


def neg_sample(self, batch):
    batch = batch.repeat(self.walks_per_node * self.num_negative_samples)

    rw = torch.randint(self.adj.sparse_size(0),
                       (batch.size(0), self.walk_length))
    rw = torch.cat([batch.view(-1, 1), rw], dim=-1)

    walks = []
    num_walks_per_rw = 1 + self.walk_length + 1 - self.context_size
    for j in range(num_walks_per_rw):
        walks.append(rw[:, j:j + self.context_size])
    return torch.cat(walks, dim=0)

Refer to PyTorch Node2Vec documentation.
