'tensor' object is not callable pytorch

The following code snippet gives the "tensor 'object is not callable" error.

I think it’s related to the “final_edge_index” tensor.

def forward(self, src, tgt, src_mask, tgt_mask,final_edge_index,batch):
“Take in and process masked src and target sequences.”
memory = self.encoder(self.src_embed(src), src_mask)
output = self.decoder(self.tgt_embed(tgt), memory, src_mask, tgt_mask,final_edge_index,batch)
return output

The value of this tensor is equal to:

tensor([[[26., 15.],
[28., 19.]],

    [[28., 19.],
     [26., 15.]]], grad_fn=<PermuteBackward>)

Based on the error message you are trying to call a tensor as a function via:

x = torch.tensor(1.)
> TypeError: 'Tensor' object is not callable

but it’s unclear where exactly this is happening based on your code and screenshot.
Could you add a minimal executable code snippet to reproduce the issue?
Also, you can post code snippets by wrapping them into three backticks ```, which makes debugging easier :wink:

thanks for your response .
On line 28 of the code below the corresponding error occurs

As you said I mistakenly called a tensor as a function
The problem was solved by converting self.tgt_embed (tgt) to self.tgt_embed