Repository: pytorch
Issue: Inductor output code source nodes is missing nodes for backwards graphs
Labels: triaged,oncall: pt2

### 🐛 Describe the bug

Steps to reproduce:

```
import torch

@torch.compile()
def f(x):
    return torch.nn.functional.gelu(x)

f(torch.randn(4, requires_grad=True, device='cuda')).sum().backward()
```

tlparse (Meta only cuz I'm lazy): https://interncache-all.fbcdn.net/manifold/tlparse_reports/tree/logs/.tmpMJ8j8V/index.html

The kernel

```
def triton_(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):                                                            
    xnumel = 4           
    xoffset = tl.program_id(0) * XBLOCK                 
    xindex = xoffset + tl.arange(0, XBLOCK)[:] 
    xmask = xindex < xnumel                                                                                                        
    x0 = xindex                                                  
    tmp0 = tl.load(in_ptr0 + (x0), xmask)              
    tmp1 = tl.load(in_ptr1 + (x0), xmask)                                                                                          
    tmp2 = 0.7071067811865476                                                                                                      
    tmp3 = tmp1 * tmp2                                           
    tmp4 = libdevice.erf(tmp3)                                   
    tmp5 = 1.0       
    tmp6 = tmp4 + tmp5                                           
    tmp7 = 0.5                                                   
    tmp8 = tmp6 * tmp7                                                                                                             
    tmp9 = tmp1 * tmp1                                           
    tmp10 = -0.5                                                 
    tmp11 = tmp9 * tmp10
    tmp12 = tl_math.exp(tmp11)                                   
    tmp13 = 0.3989422804014327                                                                                                     
    tmp14 = tmp12 * tmp13       
    tmp15 = tmp1 * tmp14        
    tmp16 = tmp8 + tmp15                                                                                                           
    tmp17 = tmp0 * tmp16                                                                                                           
    tl.store(out_ptr0 + (x0), tmp17, xmask)  
```

is annotated with

```
# kernel path: /tmp/torchinductor_ezyang/tc/ctcg6vrb3wgwmuh625mqucd4gfgje4wzwya3gslwtfgvk74ucyl5.py                                
# Source Nodes: [gelu], Original ATen: [aten.gelu, aten.gelu_backward]                                                             
# gelu => add, erf, mul_1 
```

The gelu_backward nodes are missing from the `=>` printout

```
 ===== AFTER POST GRAD =====                                                                                                       
 <eval_with_key>.2 class GraphModule(torch.nn.Module):                                                                             
    def forward(self, primals_1: "f32[4][1]cuda:0", tangents_1: "f32[4][1]cuda:0"):
         # File: /data/users/ezyang/a/pytorch/b.py:5 in f, code: return torch.nn.functional.gelu(x)                                
        mul_1: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(primals_1, 0.7071067811865476)                                        
        erf: "f32[4][1]cuda:0" = torch.ops.aten.erf.default(mul_1);  mul_1 = None                                                  
        add: "f32[4][1]cuda:0" = torch.ops.aten.add.Tensor(erf, 1);  erf = None
        mul_4: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(add, 0.5);  add = None                                                
        mul_5: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(primals_1, primals_1)                                                 
        mul_6: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(mul_5, -0.5);  mul_5 = None                                           
        exp: "f32[4][1]cuda:0" = torch.ops.aten.exp.default(mul_6);  mul_6 = None                                                  
        mul_7: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(exp, 0.3989422804014327);  exp = None
        mul_8: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(primals_1, mul_7);  primals_1 = mul_7 = None
        add_2: "f32[4][1]cuda:0" = torch.ops.aten.add.Tensor(mul_4, mul_8);  mul_4 = mul_8 = None                                  
        mul_9: "f32[4][1]cuda:0" = torch.ops.aten.mul.Tensor(tangents_1, add_2);  tangents_1 = add_2 = None                        
        return [mul_9]
```

### Versions

main

cc @anijain2305 @chauhang @penguinwu