get<1>(labelmax)==y returns a boolean tensor, but torch::mean support floating type tensor only, you have to convert this boolean tensor into float type, just like what you did in python.
Try this:
auto acc=torch::mean((get<1>(labelmax)==y)).to(torch::kFloat))