[MINIFIER] Running code snippet with  TORCHDYNAMO_REPRO_AFTER="dynamo" leads to error
Labels: triaged, oncall: pt2, module: dynamic shapes, module: minifier

### 🐛 Describe the bug

The following code snippet runs fine with `torch.compile` (mostly, aside from a fallback on aten.sort) without minifying. With `TORCHDYNAMO_REPRO_AFTER="dynamo"` an error is produced and the `minifier_launcher.py` cannot be executed.

I wasn't sure whether this would count as a `torch.compile` problem or not?

Reproducible example:
```python 
import torch

class Model(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, outputs, labels, num_masks=2):
        mask_positions = labels != -100

        # outputs = outputs[mask_positions]  # not allowed as dynamic shape op
        # torch.masked_select(labels, mask_positions)  # also not allowed as a dynamic shape operator

        indices = torch.argsort(mask_positions.int())[-num_masks:]  # ugh

        outputs = outputs[indices]  # not allowed as dynamic shape op, but ok with indices
        labels = labels[indices]

        return {"loss": outputs.mean(), "outputs": outputs}


labels = torch.ones((16,), dtype=torch.long) * -100
labels[3] = 8
labels[5] = 3
outputs = torch.randn(16, 128)
model = torch.compile(Model(), fullgraph=True, dynamic=True)
loss = model(outputs, labels)["loss"]
```

Error message with minifier:

```
[2023-03-09 17:50:42,027] torch._dynamo.symbolic_convert: [INFO] Step 1: torchdynamo start tracing forward
[2023-03-09 17:50:42,429] torch._dynamo.symbolic_convert: [INFO] Step 1: torchdynamo done tracing forward (RETURN_VALUE)
[2023-03-09 17:50:42,431] torch._dynamo.output_graph: [INFO] Step 2: calling compiler function debug_wrapper
[2023-03-09 17:50:42,875] torch._inductor.compile_fx: [INFO] Step 3: torchinductor compiling FORWARDS graph 0
[2023-03-09 17:50:42,879] torch._inductor.graph: [INFO] Using FallbackKernel: aten.sort
[2023-03-09 17:50:44,780] torch._inductor.compile_fx: [INFO] Step 3: torchinductor done compiling FORWARDS graph 0
[2023-03-09 17:50:44,783] torch._dynamo.debug_utils: [WARNING] Compiled Fx GraphModule failed. Creating script to minify the error.
[2023-03-09 17:50:44,785] torch._dynamo.debug_utils: [WARNING] Writing minified repro to [.../torch_compile_debug/run_2023_03_09_17_50_44_784924-pid_141514/minifier/minifier_launcher.py
[2023-03-09 17:50:44,785] torch._dynamo.debug_utils: [WARNING] Compiled Fx GraphModule failed. Creating script to minify the error.
[2023-03-09 17:50:44,786] torch._dynamo.debug_utils: [WARNING] Writing minified repro to /torch_compile_debug/run_2023_03_09_17_50_44_784924-pid_141514/minifier/minifier_launcher.py
Traceback (most recent call last):
  File "minimal_error.py", line 53, in <module>
    loss = model(outputs, labels)["loss"]
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 95, in __call__
    return self.dynamo_ctx(self._orig_mod.__call__)(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 231, in _fn
    return fn(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1533, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 368, in catch_errors
    return callback(frame, cache_size, hooks)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 164, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 530, in transform_code_object
    transformations(instructions, code_options)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1839, in run
    super().run()
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 596, in run
    and self.step()
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 560, in step
    getattr(self, inst.opname)(inst)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1918, in RETURN_VALUE
    self.output.compile_subgraph(
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 575, in compile_subgraph
    self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 622, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 164, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 708, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 704, in call_user_compiler
    compiled_fn = compiler_fn(gm, self.fake_example_inputs())
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/debug_utils.py", line 1031, in debug_wrapper
    compiled_gm = compiler_fn(copy.deepcopy(gm), example_inputs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/debug_utils.py", line 1032, in debug_wrapper
    run_fwd_maybe_bwd(compiled_gm, example_inputs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/debug_utils.py", line 633, in run_fwd_maybe_bwd
    out = gm(args)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1222, in g
    return f(*args)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 231, in _fn
    return fn(*args, **kwargs)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 2847, in forward
    return compiled_fn(full_args)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1222, in g
    return f(*args)
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1901, in runtime_wrapper
    all_outs = call_func_with_args(
  File "/home/jonas/miniconda3/envs/dl/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1247, in call_func_with_args
    out = normalize_as_list(f(args))
  File "/tmp/torchinductor_jonas/6x/c6xwttnuklgllfqp6jhtkgsip4mlmqx5s56fo2h3ejkhrpp2blwz.py", line 103, in call
    buf0 = empty_strided((s0, ), (1, ), device='cpu', dtype=torch.int32)
torch._dynamo.exc.BackendCompilerFailed: backend='debug_wrapper' raised:
RuntimeError: /opt/conda/conda-bld/pytorch_1678176698518/work/build/aten/src/ATen/RegisterCPU.cpp:5148: SymIntArrayRef expected to contain only concrete integers

Minifier script written to [...] minifier/minifier_launcher.py. Run this script to find the smallest traced graph which reproduces this error.

```

Subsequent error on minifier script:

```
/torch_compile_debug/run_2023_03_09_17_50_44_784924-pid_141514/minifier/minifier_launcher.py
Traceback (most recent call last):
  File "/torch_compile_debug/run_2023_03_09_17_50_44_784924-pid_141514/minifier/minifier_launcher.py", line 24, in <module>
    args = [((s0, s1), (s1, 1), torch.float32, 'cpu', False), ((s0,), (1,), torch.int64, 'cpu', False)]
NameError: name 's0' is not defined
```


### Versions

```
PyTorch version: 2.1.0.dev20230307
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Pop!_OS 22.04 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.10.9 (main, Mar  1 2023, 18:23:06) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.2.0-76060200-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.5.119
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3050 Ti Laptop GPU
Nvidia driver version: 525.85.05
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
```

cc @ezyang @soumith @msaroufim @wconstab @ngimel @bdhirsh