Repository: pytorch
Issue: torch.cond export succeeds with strict, fails in non-strict with "Could not extract specialized integer from data-dependent expression"
Labels: oncall: pt2,oncall: export

### 🐛 Describe the bug

This is a synthetic example I generated while trying to make a reproducer for https://fb.workplace.com/groups/6829516587176185/posts/7705964779531357/ So I don't care about it per se but it might shed light on some preexisting problem you may want to fix.

This test

```python
    def test_cond_contains_unbacked_no_escape(self):
        class M(torch.nn.Module):
            def forward(self, a, b):
                az = a.nonzero()

                def true_fn(x):
                    b0 = b.item()
                    return x * b0

                def false_fn(x):
                    return x + 1

                r = torch.cond(az.size(0) > 3, true_fn, false_fn, (az,))
                return r * 2

        args = (torch.randn(7), torch.tensor([4]))
        M()(*args)
        torch.export.export(M(), args, strict=False)
```

passes when strict=True, but fails with strict=False:

```
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/lazy.py", line 29, in realize          
    self.vt = VariableBuilder(tx, self.source)(self.value)
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 375, in __call__
    vt = self._wrap(value)                                                  
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 541, in _wrap
    return type_dispatch(self, value)
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 1586, in wrap_tensor  
    tensor_variable = wrap_fx_proxy(
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 2030, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)      
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 2142, in wrap_fx_proxy_cls
    example_value = wrap_to_fake_tensor_and_record(
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 2697, in wrap_to_fake_tensor_and_record
    fake_e = wrap_fake_exception(
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/utils.py", line 1574, in wrap_fake_exception
    return fn()
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 2698, in <lambda>
    lambda: tx.fake_mode.from_tensor(                                       
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/fake_tensor.py", line 2250, in from_tensor
    return self.fake_tensor_converter.from_real_tensor(
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/fake_tensor.py", line 374, in from_real_tensor
    out = self.meta_converter(
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/meta_utils.py", line 1660, in __call__
    r = self.meta_tensor(
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/meta_utils.py", line 1441, in meta_tensor
    ) = sym_sizes_strides_storage_offset(t, source, symbolic_context)
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/meta_utils.py", line 753, in sym_sizes_strides_storage_offset                                     
    t_size = tuple(
  File "/data/users/ezyang/a/pytorch/torch/_subclasses/meta_utils.py", line 754, in <genexpr>                                                            
    shape_env._maybe_specialize_sym_int_with_hint(sz)                                                                                                    
  File "/data/users/ezyang/a/pytorch/torch/fx/experimental/symbolic_shapes.py", line 3073, in _maybe_specialize_sym_int_with_hint
    return maybe_sym.node.require_hint()                                                                                                                 
  File "/data/users/ezyang/a/pytorch/torch/fx/experimental/sym_node.py", line 183, in require_hint  
    return self.shape_env.size_hint(self.expr)
  File "/data/users/ezyang/a/pytorch/torch/fx/experimental/symbolic_shapes.py", line 4668, in size_hint                                                  
    raise self._make_data_dependent_error(result_expr, expr)                                                                                             
torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not extract specialized integer from data-dependent expression u0 (unhinted: u0)
.  (Size-like symbols: u0)
                                                                            
Potential framework code culprit (scroll up for full backtrace):
  File "/data/users/ezyang/a/pytorch/torch/_dynamo/variables/builder.py", line 2698, in <lambda>
    lambda: tx.fake_mode.from_tensor(
```

It looks related to how we try to get hints for the outer variables but fail to do so. @ydwu4 didn't you patch one of these for a different case? Here's another one.

cc @chauhang @penguinwu @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4 @pianpwk @zou3519 

### Versions

main