完整报错信息:
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: derivative for aten::_scaled_dot_product_efficient_attention_backward is not implemented
有可能真的不是你的写的backward有问题,而是你的环境有问题,莫名其妙,换了一个之前的环境就好了。