[ONNX] Update inputs/input_names formatting to avoid ValueError with scriptMethods (#53519) (#53548)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53548

fixes issue faced in #53506

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D26922415

Pulled By: malfet

fbshipit-source-id: b61842827bb14cef8c7a7089b2426fa53e642c90
diff --git a/torch/onnx/utils.py b/torch/onnx/utils.py
index cd4c9a4..80f2d86 100644
--- a/torch/onnx/utils.py
+++ b/torch/onnx/utils.py
@@ -344,13 +344,16 @@
             args = tuple(args)
         return args
     # Cases of models without forward functions and dict inputs
-    except AttributeError:
+    except (AttributeError, ValueError):
         warnings.warn("Model has no forward function")
         return args
     # Cases of models with no input args
     except IndexError:
         warnings.warn("No input args")
         return args
+    except Exception as e:
+        warnings.warn("Skipping _decide_input_format\n {}".format(e.args[0]))
+        return args
 
 def _trace(func, args, operator_export_type, return_outs=False):
     # Special case for common case of passing a single Tensor