Repository: pytorch
Issue: Inductor doesn't support fallback ops that return int: AssertionError: <class 'sympy.core.symbol.Symbol'>
Labels: triaged,oncall: pt2,module: inductor

### 🐛 Describe the bug

```
import torch.library
from typing import Tuple

@torch.library.custom_op(
    "mylib::index_op", mutates_args=(), device_types=["cpu"]
)
def index_op(indices: Tensor, values: Tensor) -> Tuple[int, Tensor]:
    u0 = indices.max().item()
    return u0, (values + u0).clone()

def index_op_backward(ctx, _grad_u0, grad):
   u0 = ctx.u0
   return None, grad * u0

def index_op_setup_context(ctx, inputs, output):
   indices, values = inputs
   u0, out = output
   ctx.u0 = u0
   # ctx.save_for_backward(u0)

torch.library.register_autograd(
    "mylib::index_op", index_op_backward, setup_context=index_op_setup_context)

@torch.library.register_fake("mylib::index_op")
def _(indices: Tensor, values: Tensor):
    u0 = torch.library.get_ctx().new_dynamic_size()
    return u0, torch.empty_like(values)

@torch.compile(backend="inductor")
def cf_index_op(indices, values):
    return index_op(indices, values)

@run_test
def test_index_op():
    x = torch.randn(20, requires_grad=True)
    r = cf_index_op(torch.tensor([0, 1, 2]), x)
    r[1].sum().backward()
```

fails with

```
    compiled_graph = fx_codegen_and_compile(
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/runtime/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/compile_fx.py", line 760, in fx_codegen_and_compile
    graph.run(*example_inputs)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_dynamo/utils.py", line 273, in time_wrapper
    r = func(*args, **kwargs)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/graph.py", line 715, in run
    return super().run(*args)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/fx/interpreter.py", line 145, in run
    self.env[node] = self.run_node(node)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/graph.py", line 1184, in run_node
    result = super().run_node(n)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/fx/interpreter.py", line 202, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/graph.py", line 1031, in output
    result = [ir.ExternKernel.realize_input(x) for x in result]
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/graph.py", line 1031, in <listcomp>
    result = [ir.ExternKernel.realize_input(x) for x in result]
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/ir.py", line 4208, in realize_input
    return cls.realize_input(x.data)
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/ir.py", line 4220, in realize_input
    x.realize()
  File "/mnt/xarfuse/uid-128580/377d4302-seed-nspid4026531836_cgpid58278121-ns-4026531840/torch/_inductor/ir.py", line 7251, in realize
    assert isinstance(self.data, (Pointwise, Reduction, Scan)), type(self.data)
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
AssertionError: <class 'sympy.core.symbol.Symbol'>

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True
```

### Versions

main

cc @msaroufim @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire