Repository: onnx/onnx
Pull request: Fix a few crashes while running shape inference
### Description
Fixes #6186, #6185, #6180, #6187.

It also improves the error messages to let users know where something is going wrong.


Problem statement:
onnx.checker crashes on STFT
# Bug Report

### Describe the bug
```
#!/usr/bin/env python
import onnx
import onnx.parser

modeltxt = """
<
   ir_version: 10,
   opset_import: ["" : 17]
>
graph (float16[3] in0, int32[2] in1, float16[7,8,8,8] in2, int32[8,1,7,2] in3) => () {
   out0 = STFT (in0, in1, in2, in3)
}
"""

model = onnx.parser.parse_model(modeltxt)
print("Parser: Passed")
onnx.checker.check_model(model, full_check=True)
print("Checker: Passed")
onnx.shape_inference.infer_shapes(model)

```
crashes with
```
Parser: Passed
[1]    187375 segmentation fault  ./repro_bug.py
```

### System information
- OS Platform and Distribution (*. Linux Ubuntu 20.04*): Linux Ubuntu 20.04
- ONNX version (*e.g. 1.13*): 1.16.1
- Python version: 3.10.12

### Expected behavior
No crash, but an error that the model is invalid

Hints from issue discussion:

Commit message: lint

Signed-off-by: Xavier Dupre <xadupre@microsoft.com>

Patch to review:
diff --git a/onnx/defs/math/defs.cc b/onnx/defs/math/defs.cc
index c315a2a7b7f..58963154ab6 100644
--- a/onnx/defs/math/defs.cc
+++ b/onnx/defs/math/defs.cc
@@ -3472,6 +3472,9 @@ ONNX_OPERATOR_SET_SCHEMA(
           }
 
           auto& input_shape = getInputShape(ctx, 0);
+          if (input_shape.dim_size() < 2) {
+            fail_shape_inference("First input should have at least 2 dimensions in ", ctx.getDisplayName(), ".");
+          }
           auto signal_dim = input_shape.dim(1);
           if (!signal_dim.has_dim_value()) {
             return;
diff --git a/onnx/defs/nn/defs.cc b/onnx/defs/nn/defs.cc
index be6a851dc25..fad595d0b30 100644
--- a/onnx/defs/nn/defs.cc
+++ b/onnx/defs/nn/defs.cc
@@ -126,6 +126,9 @@ void convPoolShapeInference(
             residual -= stride;
           }
         }
+        if (i >= static_cast<int>(effective_kernel_shape.size())) {
+          fail_shape_inference("kernel shape should have ", input_dims_size, " values in ", ctx.getDisplayName(), ".");
+        }
         int64_t total_pad = residual == 0 ? effective_kernel_shape[i] - stride : effective_kernel_shape[i] - residual;
         if (total_pad < 0)
           total_pad = 0;
@@ -959,19 +962,21 @@ ONNX_OPERATOR_SET_SCHEMA(
           auto w_type = ctx.getInputType(3);
           if (nullptr == x_type || nullptr == w_type || x_type->value_case() != TypeProto::kTensorType ||
               w_type->value_case() != TypeProto::kTensorType) {
-            fail_type_inference("inputs are expected to have tensor type.");
+            fail_type_inference("inputs are expected to have tensor type in ", ctx.getDisplayName(), ".");
           }
 
           auto x_zero_point_type = ctx.getInputType(2);
           if (nullptr == x_zero_point_type ||
               x_zero_point_type->tensor_type().elem_type() != x_type->tensor_type().elem_type()) {
-            fail_type_inference("input and zero_point pair is expected to have be same type.");
+            fail_type_inference(
+                "input and zero_point pair is expected to have be same type in ", ctx.getDisplayName(), ".");
           }
 
           auto w_zero_point_type = ctx.getInputType(5);
           if (nullptr == w_zero_point_type ||
               w_zero_point_type->tensor_type().elem_type() != w_type->tensor_type().elem_type()) {
-            fail_type_inference("weight and zero_point pair is expected to have same type.");
+            fail_type_inference(
+                "weight and zero_point pair is expected to have same type in ", ctx.getDisplayName(), ".");
           }
 
           propagateElemTypeFromInputToOutput(ctx, 7, 0);
@@ -2647,7 +2652,8 @@ ONNX_OPERATOR_SET_SCHEMA(
           if (!hasNInputShapes(ctx, 1)) {
             return;
           }
-          auto& input_shape = ctx.getInputType(0)->tensor_type().shape();
+
+          auto& input_shape = getInputShape(ctx, 0);
           int64_t input_ndim = input_shape.dim_size();
           int64_t axis = -1;
           auto axis_proto = ctx.getAttribute("axis");
@@ -2659,7 +2665,16 @@ ONNX_OPERATOR_SET_SCHEMA(
             // positive value.
             axis += input_ndim;
           }
-
+          if (axis < 0) {
+            fail_shape_inference(
+                "Unexpected axis value (",
+                axis,
+                ") rank of first input is ",
+                input_ndim,
+                " in ",
+                ctx.getDisplayName(),
+                ".");
+          }
           if (ctx.getNumOutputs() > 1) {
             auto mean_shape = ctx.getOutputType(1)->mutable_tensor_type()->mutable_shape();
             mean_shape->CopyFrom(input_shape);
diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
index 57f8e2a4fdf..8b2dc07fbbb 100644
--- a/onnx/defs/nn/old.cc
+++ b/onnx/defs/nn/old.cc
@@ -201,6 +201,9 @@ void convPoolShapeInference_opset19(
             residual -= stride;
           }
         }
+        if (i >= static_cast<int>(effective_kernel_shape.size())) {
+          fail_shape_inference("kernel shape should have ", input_dims_size, " values in ", ctx.getDisplayName(), ".");
+        }
         int64_t total_pad = residual == 0 ? effective_kernel_shape[i] - stride : effective_kernel_shape[i] - residual;
         if (total_pad < 0)
           total_pad = 0;
diff --git a/onnx/defs/shape_inference.h b/onnx/defs/shape_inference.h
index a80473b386c..4c7833e3112 100644
--- a/onnx/defs/shape_inference.h
+++ b/onnx/defs/shape_inference.h
@@ -105,6 +105,8 @@ struct InferenceContext {
   virtual const SparseTensorProto* getInputSparseData(size_t index) const = 0;
   // Gets the shape inputs computed by partial data propagation.
   virtual const TensorShapeProto* getSymbolicInput(size_t index) const = 0;
+  // To display a name the user can use to narrow its search.
+  virtual std::string getDisplayName() const = 0;
 };
 
 // We use data propagation to perform partial evaluation of the model, to compute statically
@@ -263,7 +265,15 @@ inline void propagateElemTypeFromDtypeToOutput(
   } else {
     // This is not expected to happen
     fail_type_inference(
-        "Output ", outputIndex, " expected to have: ", expected_value_case, " or UNDEFINED. Got: ", output_value_case);
+        "Output ",
+        outputIndex,
+        " expected to have: ",
+        expected_value_case,
+        " or UNDEFINED. Got: ",
+        output_value_case,
+        " in ",
+        ctx.getDisplayName(),
+        ".");
   }
 }
 
@@ -277,18 +287,18 @@ inline void propagateElemTypeFromDtypeToOutput(InferenceContext& ctx, const Attr
   const auto attr_type = attr->type();
   if (attr_type == AttributeProto::TENSOR) {
     if (attr->t().dims().size() != 1) {
-      fail_type_inference("Attribute expected to have a one-dim tensor");
+      fail_type_inference("Attribute expected to have a one-dim tensor in ", ctx.getDisplayName(), ".");
     }
     data_type = attr->t().data_type();
     expected_value_case = TypeProto::kTensorType;
   } else if (attr_type == AttributeProto::SPARSE_TENSOR) {
     if (attr->sparse_tensor().dims().size() != 1) {
-      fail_type_inference("Attribute expected to have a one-dim sparse tensor");
+      fail_type_inference("Attribute expected to have a one-dim sparse tensor in ", ctx.getDisplayName(), ".");
     }
     data_type = attr->sparse_tensor().values().data_type();
     expected_value_case = TypeProto::kSparseTensorType;
   } else {
-    fail_type_inference("Attribute expected to have tensor or sparse tensor type");
+    fail_type_inference("Attribute expected to have tensor or sparse tensor type in ", ctx.getDisplayName(), ".");
   }
 
   propagateElemTypeFromDtypeToOutput(ctx, data_type, outputIndex, expected_value_case);
@@ -326,7 +336,10 @@ inline const TensorShapeProto& getInputShape(const InferenceContext& ctx, size_t
   const auto* input_type = ctx.getInputType(n);
   const auto value_case = input_type->value_case();
   if (value_case != TypeProto::kTensorType && value_case != TypeProto::kSparseTensorType) {
-    fail_type_inference("Attribute expected to have tensor or sparse tensor type");
+    fail_type_inference("Input ", n, "expected to be a tensor or a sparse tensor type in ", ctx.getDisplayName(), ".");
+  }
+  if (!hasShape(*input_type)) {
+    fail_shape_inference("Input ", n, " must have a non null shape in ", ctx.getDisplayName(), ".");
   }
   if (value_case == TypeProto::kTensorType) {
     return input_type->tensor_type().shape();
@@ -344,7 +357,7 @@ inline const TensorShapeProto* getOptionalInputShape(InferenceContext& ctx, size
 
   const auto value_case = input_type->value_case();
   if (value_case != TypeProto::kTensorType && value_case != TypeProto::kSparseTensorType) {
-    fail_type_inference("Attribute expected to have tensor or sparse tensor type");
+    fail_type_inference("Input ", n, "expected to be a tensor or a sparse tensor type in ", ctx.getDisplayName(), ".");
   }
   if (value_case == TypeProto::kTensorType) {
     return &input_type->tensor_type().shape();
@@ -372,7 +385,10 @@ inline void appendSingleDimCopiedFromInputTypeToOutputType(
         " does not match type of output: ",
         outputIndex,
         "type: ",
-        output_value_case);
+        output_value_case,
+        " in ",
+        ctx.getDisplayName(),
+        ".");
   }
   if (TypeProto::kTensorType == input_value_case) {
     auto* dim = output_type->mutable_tensor_type()->mutable_shape()->add_dim();
@@ -382,7 +398,13 @@ inline void appendSingleDimCopiedFromInputTypeToOutputType(
     *dim = input_type->sparse_tensor_type().shape().dim(static_cast<int>(fromDimIndex));
   } else {
     fail_type_inference(
-        "Input ", inputIndex, " and Output ", outputIndex, " expected to have tensor or sparse tensor type");
+        "Input ",
+        inputIndex,
+        " and Output ",
+        outputIndex,
+        " expected to have tensor or sparse tensor type in ",
+        ctx.getDisplayName(),
+        ".");
   }
 }
 
@@ -440,7 +462,14 @@ updateOutputElemType(InferenceContext& ctx, size_t outputIndex, int32_t elemType
     setTensorElementType(elemType, expected_type, *output_type);
   } else {
     // This is not expected to happen
-    fail_type_inference("Output ", outputIndex, " expected to have tensor or sparse tensor type: ", expected_type);
+    fail_type_inference(
+        "Output ",
+        outputIndex,
+        " expected to have tensor or sparse tensor type: ",
+        expected_type,
+        " in ",
+        ctx.getDisplayName(),
+        ".");
   }
 }
 
@@ -462,16 +491,17 @@ inline void propagateElemTypeFromAttributeToOutput(
       updateOutputElemType(ctx, outputIndex, default_value, expected_type);
       return;
     } else {
-      fail_type_inference("Value of attribute ", attributeName, " not specified");
+      fail_type_inference("Value of attribute ", attributeName, " not specified in ", ctx.getDisplayName(), ".");
     }
   }
   if (!attr_proto->has_i()) {
-    fail_type_inference("Attribute ", attributeName, " should be of integer type and specify a type.");
+    fail_type_inference(
+        "Attribute ", attributeName, " should be of integer type and specify a type in ", ctx.getDisplayName(), ".");
   }
   auto attr_value = attr_proto->i();
   auto elem_type = static_cast<TensorProto_DataType>(attr_value);
   if (!TensorProto_DataType_IsValid(elem_type)) {
-    fail_type_inference("Attribute ", attributeName, " does not specify a valid type.");
+    fail_type_inference("Attribute ", attributeName, " does not specify a valid type in ", ctx.getDisplayName(), ".");
   }
   updateOutputElemType(ctx, outputIndex, elem_type, expected_type);
 }
@@ -497,7 +527,7 @@ inline TensorShapeProto*
 getOutputShape(InferenceContext& ctx, size_t n, TypeProto::ValueCase default_type = TypeProto::kTensorType) {
   auto output_type = ctx.getOutputType(n);
   if (output_type == nullptr) {
-    fail_type_inference("Output ", n, " expected to have tensor or sparse type");
+    fail_type_inference("Output ", n, " expected to have tensor or sparse type in ", ctx.getDisplayName(), ".");
   }
   const auto output_value_case = output_type->value_case();
   if (output_value_case == TypeProto::kTensorType || output_value_case == TypeProto::kSparseTensorType) {
@@ -505,7 +535,7 @@ getOutputShape(InferenceContext& ctx, size_t n, TypeProto::ValueCase default_typ
   } else if (output_value_case == TypeProto::VALUE_NOT_SET) {
     return getTensorMutableShape(default_type, *output_type);
   } else {
-    fail_type_inference("Output ", n, " expected to have tensor type");
+    fail_type_inference("Output ", n, " expected to have tensor type in ", ctx.getDisplayName(), ".");
   }
 }
 
@@ -562,13 +592,13 @@ inline void propagateShapeFromAttributeToOutput(
   auto attr_proto = ctx.getAttribute(attributeName);
   if ((nullptr == attr_proto) || (!attr_proto->has_type()) ||
       (attr_proto->type() != AttributeProto_AttributeType_INTS)) {
-    fail_shape_inference("Attribute ", attributeName, " should specify a shape");
+    fail_shape_inference("Attribute ", attributeName, " should specify a shape in ", ctx.getDisplayName(), ".");
   }
   auto& int_list = attr_proto->ints();
   TensorShapeProto shape;
   for (auto dim_size : int_list) {
     if (dim_size < 0) {
-      fail_shape_inference("Negative values are not allowed in a shape specification");
+      fail_shape_inference("Negative values are not allowed in a shape specification in ", ctx.getDisplayName(), ".");
     }
     shape.add_dim()->set_dim_value(dim_size);
   }
@@ -745,7 +775,16 @@ inline void checkInputRank(InferenceContext& ctx, size_t input_index, int expect
   if (hasInputShape(ctx, input_index)) {
     auto rank = getInputShape(ctx, input_index).dim_size();
     if (rank != expected_rank) {
-      fail_shape_inference("Input ", input_index, " expected to have rank ", expected_rank, " but has rank ", rank);
+      fail_shape_inference(
+          "Input ",
+          input_index,
+          " expected to have rank ",
+          expected_rank,
+          " but has rank ",
+          rank,
+          " in ",
+          ctx.getDisplayName(),
+          ".");
     }
   }
 }
@@ -798,7 +837,15 @@ inline void unifyInputDim(InferenceContext& ctx, size_t input_index, int dim_ind
     // This shape is expected to have rank > dim_index:
     if (input_shape.dim_size() <= dim_index) {
       fail_shape_inference(
-          "Input ", input_index, " expected to have rank >", dim_index, " but has rank ", input_shape.dim_size());
+          "Input ",
+          input_index,
+          " expected to have rank >",
+          dim_index,
+          " but has rank ",
+          input_shape.dim_size(),
+          " in ",
+          ctx.getDisplayName(),
+          ".");
     }
     const Dim& input_dim = input_shape.dim(dim_index);
     // Now, unify dim and input_dim:
diff --git a/onnx/shape_inference/implementation.cc b/onnx/shape_inference/implementation.cc
index 8723dcd4fb3..8249fc59d48 100644
--- a/onnx/shape_inference/implementation.cc
+++ b/onnx/shape_inference/implementation.cc
@@ -906,7 +906,7 @@ struct FunctionInferenceContext : public InferenceContext {
       const std::vector<TypeProto>& input_types,
       const std::vector<AttributeProto>& attributes,
       const ShapeInferenceOptions& options)
-      : input_types_(input_types), options_(options) {
+      : input_types_(input_types), options_(options), func_proto_(&func_proto) {
     for (const auto& attr : attributes) {
       attributesByName_[attr.name()] = &attr;
     }
@@ -971,11 +971,25 @@ struct FunctionInferenceContext : public InferenceContext {
     return std::move(output_types_);
   }
 
+  std::string getDisplayName() const override {
+    if (func_proto_ == nullptr)
+      return "";
+    if (func_proto_->domain().empty()) {
+      if (func_proto_->name().empty())
+        return "";
+      return MakeString("function ", func_proto_->name());
+    }
+    if (func_proto_->name().empty())
+      return MakeString("function [", func_proto_->domain(), "]");
+    return MakeString("function ", func_proto_->name(), "[", func_proto_->domain(), "]");
+  }
+
  private:
   const std::vector<TypeProto>& input_types_;
   std::vector<TypeProto> output_types_;
   std::unordered_map<std::string, const AttributeProto*> attributesByName_;
   ShapeInferenceOptions options_;
+  const FunctionProto* func_proto_;
 };
 
 std::vector<TypeProto> InferFunctionOutputTypes(
diff --git a/onnx/shape_inference/implementation.h b/onnx/shape_inference/implementation.h
index 2c63c910a06..b0e4c32df4e 100644
--- a/onnx/shape_inference/implementation.h
+++ b/onnx/shape_inference/implementation.h
@@ -146,7 +146,7 @@ struct InferenceContextImpl : public InferenceContext {
       const ShapeInferenceOptions& options,
       DataValueMap* generatedShapeData = nullptr,
       GraphInferenceContext* graphInferenceContext = nullptr)
-      : graphInferenceContext_{graphInferenceContext}, options_(options) {
+      : graphInferenceContext_{graphInferenceContext}, options_(options), node_(&n) {
     for (auto& attr : *n.mutable_attribute()) {
       attributesByName_[attr.name()] = &attr;
       if (attr.has_g()) {
@@ -277,6 +277,19 @@ struct InferenceContextImpl : public InferenceContext {
     return inferencer;
   }
 
+  std::string getDisplayName() const override {
+    if (node_ == nullptr)
+      return "";
+    if (node_->domain().empty()) {
+      if (node_->name().empty())
+        return MakeString("node ", node_->op_type());
+      return MakeString("node ", node_->op_type(), " (", node_->name(), ")");
+    }
+    if (node_->name().empty())
+      return MakeString("node ", node_->op_type(), "[", node_->domain(), "]");
+    return MakeString("node ", node_->op_type(), "[", node_->domain(), "]", " (", node_->name(), ")");
+  }
+
   std::vector<const TensorProto*> allInputData_;
   std::vector<const SparseTensorProto*> allInputSparseData_;
   std::vector<const TensorShapeProto*> allShapeInputData_;
@@ -289,6 +302,7 @@ struct InferenceContextImpl : public InferenceContext {
   // mutable as internal cache of GraphInferencer instances
   mutable std::unordered_map<std::string, std::unique_ptr<GraphInferencer>> graphAttributeInferencers_;
   ShapeInferenceOptions options_;
+  NodeProto* node_;
 };
 
 struct DataPropagationContextImpl : public DataPropagationContext {
diff --git a/onnx/test/shape_inference_test.py b/onnx/test/shape_inference_test.py
index 5b8e77df0df..1538afd05ed 100644
--- a/onnx/test/shape_inference_test.py
+++ b/onnx/test/shape_inference_test.py
@@ -1776,7 +1776,9 @@ def test_slice_with_input_shape_containing_dim_params(self) -> None:
                 make_tensor("ends", TensorProto.INT64, (3,), (1, 1, 1)),
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (1, None, 1))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (1, None, 1))]
+        )  # type: ignore
 
     def test_slice_with_input_shape_steps(self) -> None:
         graph = self._make_graph(
@@ -1900,7 +1902,9 @@ def test_slice_negative_end(self) -> None:
                 make_tensor("axes", TensorProto.INT64, (2,), (0, 1)),
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 1))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 1))]
+        )  # type: ignore
 
     def test_slice_negative_start(self) -> None:
         graph = self._make_graph(
@@ -1920,7 +1924,9 @@ def test_slice_negative_start(self) -> None:
                 make_tensor("axes", TensorProto.INT64, (2,), (0, 1)),
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 2))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 2))]
+        )  # type: ignore
 
     def test_slice_negative_step(self) -> None:
         graph = self._make_graph(
@@ -1942,7 +1948,9 @@ def test_slice_negative_step(self) -> None:
                 make_tensor("steps", TensorProto.INT64, (2,), (1, -1)),
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (2, 3))]
+        )  # type: ignore
 
     def test_slice_variable_copy(self) -> None:
         graph = self._make_graph(
@@ -1960,7 +1968,9 @@ def test_slice_variable_copy(self) -> None:
                 make_tensor("axes", TensorProto.INT64, (1,), (1,)),
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ("a", 1))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, ("a", 1))]
+        )  # type: ignore
 
     def test_slice_variable_input_types(self) -> None:
         graph = self._make_graph(
@@ -2139,7 +2149,10 @@ def test_conv_partial_missing_shape(self) -> None:
             [make_node("Conv", ["x", "y"], "z", pads=[1, 1, 2, 0, 1, 2])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (30, 50, None, 6, 6))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("z", TensorProto.FLOAT, (30, 50, None, 6, 6))],
+        )  # type: ignore
 
     def test_conv_partial_missing_weight_shape(self) -> None:
         graph = self._make_graph(
@@ -2231,7 +2244,9 @@ def test_identity_sequence(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, 4)),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, 4)
+                ),  # type: ignore
                 make_tensor_sequence_value_info(
                     "output_sequence", TensorProto.FLOAT, (2, None, 4)
                 ),
@@ -2441,7 +2456,9 @@ def test_bernoulli(self) -> None:
             [make_node("Bernoulli", ["x"], ["out"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.FLOAT, (3, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.FLOAT, (3, 4))]
+        )  # type: ignore
 
     def test_bernoulli_with_dtype(self) -> None:
         graph = self._make_graph(
@@ -2456,7 +2473,9 @@ def test_bernoulli_with_dtype(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.DOUBLE, (2, 3, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.DOUBLE, (2, 3, 4))]
+        )  # type: ignore
 
     def _logical_binary_op(self, op: str, input_type: TensorProto.DataType) -> None:
         graph = self._make_graph(
@@ -2560,7 +2579,9 @@ def test_flatten_unknown_dim(self) -> None:
             [make_node("Flatten", ["x"], ["z"], axis=2)],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (None, 20))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (None, 20))]
+        )  # type: ignore
 
     def test_space_to_depth(self) -> None:
         b = 10
@@ -2580,7 +2601,9 @@ def test_space_to_depth_unknown_dim(self) -> None:
             [make_node("SpaceToDepth", ["x"], ["z"], blocksize=b)],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, None, 10, 10))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, None, 10, 10))]
+        )  # type: ignore
 
     def test_depth_to_space(self) -> None:
         b = 10
@@ -2806,7 +2829,9 @@ def test_topk_missing_k_value_output_rank_check(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_value_info("y", TensorProto.FLOAT, (None, None, None, None)),  # type: ignore
+                make_tensor_value_info(
+                    "y", TensorProto.FLOAT, (None, None, None, None)
+                ),  # type: ignore
                 make_tensor_value_info(
                     "z", TensorProto.INT64, (None, None, None, None)
                 ),
@@ -4409,7 +4434,9 @@ def test_if_with_different_shapes_in_then_else_branches(self) -> None:
             [],
         )
 
-        self._assert_inferred(graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, (None,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, (None,))]
+        )  # type: ignore
 
     def test_if_no_shape_in_then_branch(self) -> None:
         then_graph = parse_graph(
@@ -4435,7 +4462,9 @@ def test_if_no_shape_in_then_branch(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, None)])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, None)]
+        )  # type: ignore
 
     def test_if_no_shape_in_else_branch(self) -> None:
         then_graph = parse_graph(
@@ -4461,7 +4490,9 @@ def test_if_no_shape_in_else_branch(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, None)])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("if_output", TensorProto.FLOAT, None)]
+        )  # type: ignore
 
     def test_if_with_different_optional_shapes_in_then_else_branches(self) -> None:
         # Create a simple If node where the 'then' subgraph adds to the current value, and the 'else' subgraph
@@ -4580,7 +4611,9 @@ def test_onehot_without_axis(self) -> None:
             [make_node("OneHot", ["indices", "depth", "values"], "Y")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 2, None))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 2, None))]
+        )  # type: ignore
 
     def test_onehot_with_axis(self) -> None:
         graph = self._make_graph(
@@ -4592,7 +4625,9 @@ def test_onehot_with_axis(self) -> None:
             [make_node("OneHot", ["indices", "depth", "values"], "Y", axis=1)],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, None, 3, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, None, 3, 5))]
+        )  # type: ignore
 
     def test_onehot_without_axis_2(self) -> None:
         graph = self._make_graph(
@@ -4605,7 +4640,9 @@ def test_onehot_without_axis_2(self) -> None:
             [],
             initializer=[make_tensor("depth", TensorProto.INT64, (), (256,))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 2, 256))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 2, 256))]
+        )  # type: ignore
 
     def test_onehot_with_axis_2(self) -> None:
         graph = self._make_graph(
@@ -4618,7 +4655,9 @@ def test_onehot_with_axis_2(self) -> None:
             [],
             initializer=[make_tensor("depth", TensorProto.INT64, (1,), (256,))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 256, 3, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("Y", TensorProto.FLOAT, (2, 256, 3, 5))]
+        )  # type: ignore
 
     def test_loop(self) -> None:
         # can't use self._make_graph for the subgraph as it add more inputs for the Reshape operations it inserts.
@@ -4913,7 +4952,10 @@ def test_convineteger_partial_missing_shape(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.INT32, (30, 50, None, 6, 6))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("z", TensorProto.INT32, (30, 50, None, 6, 6))],
+        )  # type: ignore
 
     def test_convineteger_partial_missing_weight_shape(self) -> None:
         graph = self._make_graph(
@@ -5136,7 +5178,10 @@ def test_qlinearconv_partial_missing_shape(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.UINT8, (30, 50, None, 6, 6))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("y", TensorProto.UINT8, (30, 50, None, 6, 6))],
+        )  # type: ignore
 
     def test_qlinearconv_partial_missing_weight_shape(self) -> None:
         graph = self._make_graph(
@@ -5567,7 +5612,9 @@ def test_tile_rank_inference(self) -> None:
             [make_node("Tile", ["x", "repeats"], ["y"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (None, None, None))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (None, None, None))]
+        )  # type: ignore
 
     @unittest.skipUnless(ONNX_ML, "ONNX_ML required to test ai.onnx.ml operators")
     def test_linearclassifier_1D_input(self) -> None:
@@ -5645,7 +5692,10 @@ def test_roialign_symbolic(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ("num_rois", "C", 10, 5))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("y", TensorProto.FLOAT, ("num_rois", "C", 10, 5))],
+        )  # type: ignore
 
     def test_roialign_symbolic_defaults(self) -> None:
         graph = self._make_graph(
@@ -5657,7 +5707,10 @@ def test_roialign_symbolic_defaults(self) -> None:
             [make_node("RoiAlign", ["x", "rois", "batch_indices"], ["y"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ("num_rois", "C", 1, 1))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("y", TensorProto.FLOAT, ("num_rois", "C", 1, 1))],
+        )  # type: ignore
 
     def test_roialign_num_rois(self) -> None:
         graph = self._make_graph(
@@ -5669,7 +5722,9 @@ def test_roialign_num_rois(self) -> None:
             [make_node("RoiAlign", ["x", "rois", "batch_indices"], ["y"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (15, "C", 1, 1))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (15, "C", 1, 1))]
+        )  # type: ignore
 
     @parameterized.expand(
         all_versions_for("LabelEncoder") if ONNX_ML else [], skip_on_empty=True
@@ -5953,7 +6008,9 @@ def test_constant_sparse(self) -> None:
         graph = self._make_graph(
             [], [make_node("Constant", [], ["y"], sparse_value=y_value)], []
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.INT64, y_shape)])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.INT64, y_shape)]
+        )  # type: ignore
 
     def test_constant_value_int(self) -> None:
         graph = self._make_graph(
@@ -6040,7 +6097,9 @@ def test_range_rank_inference(self) -> None:
                 make_tensor("limit", TensorProto.INT32, (), (5,)),
             ],
         )  # Missing 'delta' initializer
-        self._assert_inferred(graph, [make_tensor_value_info("output", TensorProto.INT32, (None,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("output", TensorProto.INT32, (None,))]
+        )  # type: ignore
 
     def test_gathernd(self) -> None:
         graph = self._make_graph(
@@ -6084,11 +6143,15 @@ def test_nonmaxsuppression(self) -> None:
             [make_node("NonMaxSuppression", ["boxes", "scores"], ["y"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.INT64, (None, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.INT64, (None, 3))]
+        )  # type: ignore
 
     def test_sequence_empty(self) -> None:
         graph = self._make_graph([], [make_node("SequenceEmpty", [], ["output"])], [])
-        self._assert_inferred(graph, [make_tensor_sequence_value_info("output", TensorProto.FLOAT, None)])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_sequence_value_info("output", TensorProto.FLOAT, None)]
+        )  # type: ignore
 
     def test_sequence_construct(self) -> None:
         graph = self._make_graph(
@@ -6261,7 +6324,9 @@ def test_sequence_insert_diff_shape(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, 4)),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, 4)
+                ),  # type: ignore
                 make_tensor_sequence_value_info(
                     "output_sequence", TensorProto.FLOAT, (2, None, None)
                 ),
@@ -6337,7 +6402,9 @@ def test_sequence_at_unknown_dim_size(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, 3, None)),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, 3, None)
+                ),  # type: ignore
                 make_tensor_value_info("output", TensorProto.FLOAT, (2, 3, None)),
             ],
         )  # type: ignore
@@ -6389,7 +6456,9 @@ def test_sequence_erase_diff_dim_size(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, "x")),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, "x")
+                ),  # type: ignore
                 make_tensor_sequence_value_info(
                     "output_sequence", TensorProto.FLOAT, (2, None, "x")
                 ),
@@ -6634,7 +6703,9 @@ def test_concat_from_sequence_unknown_dim_size(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, "x")),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, "x")
+                ),  # type: ignore
                 make_tensor_value_info("out", TensorProto.FLOAT, (None, None, "x")),
             ],
         )  # type: ignore
@@ -6657,7 +6728,9 @@ def test_concat_from_sequence_axis(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, "x")),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, "x")
+                ),  # type: ignore
                 make_tensor_value_info("out", TensorProto.FLOAT, (2, None, None)),
             ],
         )  # type: ignore
@@ -6680,7 +6753,9 @@ def test_concat_from_sequence_neg_axis(self) -> None:
         self._assert_inferred(
             graph,
             [
-                make_tensor_sequence_value_info("in_sequence", TensorProto.FLOAT, (2, None, "x")),  # type: ignore
+                make_tensor_sequence_value_info(
+                    "in_sequence", TensorProto.FLOAT, (2, None, "x")
+                ),  # type: ignore
                 make_tensor_value_info("out", TensorProto.FLOAT, (None, None, "x")),
             ],
         )  # type: ignore
@@ -7023,7 +7098,9 @@ def test_pad(self) -> None:
                 )
             ],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, None, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, None, 4))]
+        )  # type: ignore
 
     def test_gatherelements_basic(self) -> None:
         graph = self._make_graph(
@@ -7044,7 +7121,9 @@ def test_gatherelements_indices_missing_shape(self) -> None:
             [make_node("GatherElements", ["x", "indices"], ["y"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, None)])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, None)]
+        )  # type: ignore
 
     def test_einsum_transpose(self) -> None:
         graph = self._make_graph(
@@ -7052,7 +7131,9 @@ def test_einsum_transpose(self) -> None:
             [make_node("Einsum", ["x"], ["y"], equation="ij->ji")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (4, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (4, 3))]
+        )  # type: ignore
 
     def test_einsum_dot(self) -> None:
         graph = self._make_graph(
@@ -7060,7 +7141,9 @@ def test_einsum_dot(self) -> None:
             [make_node("Einsum", ["x", "y"], ["z"], equation="i,i->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_scalar(self) -> None:
         graph = self._make_graph(
@@ -7068,7 +7151,9 @@ def test_einsum_scalar(self) -> None:
             [make_node("Einsum", ["x", "y"], ["z"], equation=",->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_outer_prod(self) -> None:
         graph = self._make_graph(
@@ -7076,7 +7161,9 @@ def test_einsum_outer_prod(self) -> None:
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,ab->ijab")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 5, 7, 9))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 5, 7, 9))]
+        )  # type: ignore
 
     def test_einsum_sum_along_dim(self) -> None:
         graph = self._make_graph(
@@ -7084,7 +7171,9 @@ def test_einsum_sum_along_dim(self) -> None:
             [make_node("Einsum", ["x"], ["y"], equation="i j->i ")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_ellipsis(self) -> None:
         graph = self._make_graph(
@@ -7092,7 +7181,9 @@ def test_einsum_ellipsis(self) -> None:
             [make_node("Einsum", ["x"], ["y"], equation="... ii ->... i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4))]
+        )  # type: ignore
 
     def test_einsum_ellipsis_2(self) -> None:
         graph = self._make_graph(
@@ -7154,7 +7245,9 @@ def test_einsum_batch_matmul(self) -> None:
             [make_node("Einsum", ["x", "y"], ["z"], equation="bij , b jk-> bik")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (5, 2, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (5, 2, 4))]
+        )  # type: ignore
 
     def test_einsum_left_hand_eqn(self) -> None:
         graph = self._make_graph(
@@ -7162,7 +7255,9 @@ def test_einsum_left_hand_eqn(self) -> None:
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,kl")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3, 4))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3, 4))]
+        )  # type: ignore
 
     def test_einsum_incorrect_num_inputs(self) -> None:
         graph = self._make_graph(
@@ -7182,7 +7277,9 @@ def test_einsum_view_A1(self) -> None:  # returns a view of A1
             [make_node("Einsum", ["x"], ["y"], equation="i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_sum_A1(self) -> None:  # sums the values of A1
         graph = self._make_graph(
@@ -7190,7 +7287,9 @@ def test_einsum_sum_A1(self) -> None:  # sums the values of A1
             [make_node("Einsum", ["x"], ["y"], equation="i->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_element_wise_multiplication_A1_B1(
         self,
@@ -7200,7 +7299,9 @@ def test_einsum_element_wise_multiplication_A1_B1(
             [make_node("Einsum", ["x", "y"], ["z"], equation="i,i->i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_inner_product_A1_B1(self) -> None:  # inner product of A1 and B1
         graph = self._make_graph(
@@ -7208,7 +7309,9 @@ def test_einsum_inner_product_A1_B1(self) -> None:  # inner product of A1 and B1
             [make_node("Einsum", ["x", "y"], ["z"], equation="i,i->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_outer_product_A1_B1(self) -> None:  # outer product of A1 and B1
         graph = self._make_graph(
@@ -7216,7 +7319,9 @@ def test_einsum_outer_product_A1_B1(self) -> None:  # outer product of A1 and B1
             [make_node("Einsum", ["x", "y"], ["z"], equation="i,j->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_view_A2(self) -> None:  # returns a view of A2
         graph = self._make_graph(
@@ -7224,7 +7329,9 @@ def test_einsum_view_A2(self) -> None:  # returns a view of A2
             [make_node("Einsum", ["x"], ["y"], equation="ij->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_view_A2_2(self) -> None:  # returns a view of A2, another case
         graph = self._make_graph(
@@ -7232,7 +7339,9 @@ def test_einsum_view_A2_2(self) -> None:  # returns a view of A2, another case
             [make_node("Einsum", ["x"], ["y"], equation="ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_transpose_A2(self) -> None:  # view transpose of A2
         graph = self._make_graph(
@@ -7240,7 +7349,9 @@ def test_einsum_transpose_A2(self) -> None:  # view transpose of A2
             [make_node("Einsum", ["x"], ["y"], equation="ji")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_transpose_A2_to_ij(self) -> None:  # view transpose of A2
         graph = self._make_graph(
@@ -7248,7 +7359,9 @@ def test_einsum_transpose_A2_to_ij(self) -> None:  # view transpose of A2
             [make_node("Einsum", ["x"], ["y"], equation="ji->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_diag_A2(self) -> None:  # view main diagonal of A2
         graph = self._make_graph(
@@ -7256,7 +7369,9 @@ def test_einsum_diag_A2(self) -> None:  # view main diagonal of A2
             [make_node("Einsum", ["x"], ["y"], equation="ii->i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_trace_A2(self) -> None:  # sums main diagonal of A2
         graph = self._make_graph(
@@ -7264,7 +7379,9 @@ def test_einsum_trace_A2(self) -> None:  # sums main diagonal of A2
             [make_node("Einsum", ["x"], ["y"], equation="ii->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_sum_A2(self) -> None:  # sums the values of A2
         graph = self._make_graph(
@@ -7272,7 +7389,9 @@ def test_einsum_sum_A2(self) -> None:  # sums the values of A2
             [make_node("Einsum", ["x"], ["y"], equation="ij->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_einsum_sum_columns_A2(
         self,
@@ -7282,7 +7401,9 @@ def test_einsum_sum_columns_A2(
             [make_node("Einsum", ["x"], ["y"], equation="ij->j")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_sum_rows_A2(self) -> None:  # sum horizontally along the rows of A2
         graph = self._make_graph(
@@ -7290,7 +7411,9 @@ def test_einsum_sum_rows_A2(self) -> None:  # sum horizontally along the rows of
             [make_node("Einsum", ["x"], ["y"], equation="ij->i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_element_wise_multiplication_A2_B2(
         self,
@@ -7300,7 +7423,9 @@ def test_einsum_element_wise_multiplication_A2_B2(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,ij->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_element_wise_multiplication_A2_B2_transpose(
         self,
@@ -7310,7 +7435,9 @@ def test_einsum_element_wise_multiplication_A2_B2_transpose(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,ji->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_matrix_multiplication_A2_B2(
         self,
@@ -7320,7 +7447,9 @@ def test_einsum_matrix_multiplication_A2_B2(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,jk")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_matrix_multiplication_A2_B2_to_ik(
         self,
@@ -7330,7 +7459,9 @@ def test_einsum_matrix_multiplication_A2_B2_to_ik(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,jk->ik")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_matrix_multiplication_A3_B3(
         self,
@@ -7340,7 +7471,9 @@ def test_einsum_matrix_multiplication_A3_B3(
             [make_node("Einsum", ["x", "y"], ["z"], equation="bij,bjk->bik")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3))]
+        )  # type: ignore
 
     def test_einsum_matrix_multiplication_A3_B3_transpose(
         self,
@@ -7350,7 +7483,9 @@ def test_einsum_matrix_multiplication_A3_B3_transpose(
             [make_node("Einsum", ["x", "y"], ["z"], equation="bij,bkj->bik")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 3, 3))]
+        )  # type: ignore
 
     def test_einsum_inner_product_A2_B2(self) -> None:  # inner product of A2 and B2
         graph = self._make_graph(
@@ -7358,7 +7493,9 @@ def test_einsum_inner_product_A2_B2(self) -> None:  # inner product of A2 and B2
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,kj->ik")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_row_multiplication_A2_B2(
         self,
@@ -7368,7 +7505,9 @@ def test_einsum_row_multiplication_A2_B2(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,kj->ikj")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3, 3))]
+        )  # type: ignore
 
     def test_einsum_value_multiplication_A2_B2(
         self,
@@ -7378,7 +7517,9 @@ def test_einsum_value_multiplication_A2_B2(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,kl->ijkl")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3, 3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3, 3, 3))]
+        )  # type: ignore
 
     def test_einsum_scalar_times_array(self) -> None:  # Scalar times array
         graph = self._make_graph(
@@ -7386,7 +7527,9 @@ def test_einsum_scalar_times_array(self) -> None:  # Scalar times array
             [make_node("Einsum", ["x", "y"], ["z"], equation=",ij->ij")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3, 3))]
+        )  # type: ignore
 
     def test_einsum_matrix_vector_A2_B1(self) -> None:  # Matrix and vector.
         graph = self._make_graph(
@@ -7394,7 +7537,9 @@ def test_einsum_matrix_vector_A2_B1(self) -> None:  # Matrix and vector.
             [make_node("Einsum", ["x", "y"], ["z"], equation="ij,j->i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_diag_multiplication_A2_B2(
         self,
@@ -7404,7 +7549,9 @@ def test_einsum_diag_multiplication_A2_B2(
             [make_node("Einsum", ["x", "y"], ["z"], equation="ii,ii->i")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (3,))]
+        )  # type: ignore
 
     def test_einsum_diag_dot_product_A2_B2(self) -> None:  # dot product of diagonals
         graph = self._make_graph(
@@ -7412,7 +7559,9 @@ def test_einsum_diag_dot_product_A2_B2(self) -> None:  # dot product of diagonal
             [make_node("Einsum", ["x", "y"], ["z"], equation="ii,ii->")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NCdd(self) -> None:
         N, C = 3, 4
@@ -7428,7 +7577,9 @@ def test_negative_log_likehood_shape_is_NCdd(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N,))]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NC_with_weight(self) -> None:
         N, C = 3, 4
@@ -7448,7 +7599,9 @@ def test_negative_log_likehood_shape_is_NC_with_weight(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N,))]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NC_reduction_mean(self) -> None:
         N, C = 3, 4
@@ -7464,7 +7617,9 @@ def test_negative_log_likehood_shape_is_NC_reduction_mean(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NC_with_weight_reduction_mean(self) -> None:
         N, C = 3, 4
@@ -7484,7 +7639,9 @@ def test_negative_log_likehood_shape_is_NC_with_weight_reduction_mean(self) -> N
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NCd1d2(self) -> None:
         N, C, d1, d2 = 3, 4, 5, 6
@@ -7503,7 +7660,9 @@ def test_negative_log_likehood_shape_is_NCd1d2(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N, d1, d2))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N, d1, d2))]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NCd1d2_with_weight(self) -> None:
         N, C, d1, d2 = 3, 4, 5, 6
@@ -7523,7 +7682,9 @@ def test_negative_log_likehood_shape_is_NCd1d2_with_weight(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N, d1, d2))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, (N, d1, d2))]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NCd1d2_reduction_sum(self) -> None:
         N, C, d1, d2 = 3, 4, 5, 6
@@ -7542,7 +7703,9 @@ def test_negative_log_likehood_shape_is_NCd1d2_reduction_sum(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_negative_log_likehood_shape_is_NCd1d2_with_weight_reduction_mean(
         self,
@@ -7564,7 +7727,9 @@ def test_negative_log_likehood_shape_is_NCd1d2_with_weight_reduction_mean(
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("loss", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_negative_log_likehood_input_target_shape_mismatch(self) -> None:
         N, C, d1, d2 = 3, 4, 5, 6
@@ -7614,7 +7779,9 @@ def test_softmax_cross_entropy_none(self) -> None:
             [make_node("SoftmaxCrossEntropyLoss", ["x", "y"], ["z"], reduction="none")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2,))]
+        )  # type: ignore
 
     def test_softmax_cross_entropy_mean(self) -> None:
         graph = self._make_graph(
@@ -7622,7 +7789,9 @@ def test_softmax_cross_entropy_mean(self) -> None:
             [make_node("SoftmaxCrossEntropyLoss", ["x", "y"], ["z"], reduction="mean")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_softmax_cross_entropy_none_NCD1D2(self) -> None:
         graph = self._make_graph(
@@ -7633,7 +7802,9 @@ def test_softmax_cross_entropy_none_NCD1D2(self) -> None:
             [make_node("SoftmaxCrossEntropyLoss", ["x", "y"], ["z"], reduction="none")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 5, 8))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, (2, 5, 8))]
+        )  # type: ignore
 
     def test_softmax_cross_entropy_mean_NCD1D2(self) -> None:
         graph = self._make_graph(
@@ -7644,7 +7815,9 @@ def test_softmax_cross_entropy_mean_NCD1D2(self) -> None:
             [make_node("SoftmaxCrossEntropyLoss", ["x", "y"], ["z"], reduction="mean")],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("z", TensorProto.FLOAT, ())]
+        )  # type: ignore
 
     def test_celu_function_output_shape(self) -> None:
         graph = self._make_graph(
@@ -7793,7 +7966,9 @@ def test_trilu_upper(self) -> None:
             [],
             initializer=[make_tensor("k", TensorProto.INT64, (), (2,))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4, 5))]
+        )  # type: ignore
 
     def test_trilu_lower(self) -> None:
         graph = self._make_graph(
@@ -7802,7 +7977,9 @@ def test_trilu_lower(self) -> None:
             [],
             initializer=[make_tensor("k", TensorProto.INT64, (), (10,))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.FLOAT, (3, 4, 5))]
+        )  # type: ignore
 
     def test_trilu_upper_zero(self) -> None:
         graph = self._make_graph(
@@ -7811,7 +7988,9 @@ def test_trilu_upper_zero(self) -> None:
             [],
             initializer=[make_tensor("k", TensorProto.INT64, (), (5,))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.INT64, (0, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.INT64, (0, 5))]
+        )  # type: ignore
 
     def test_trilu_lower_one(self) -> None:
         graph = self._make_graph(
@@ -7819,7 +7998,9 @@ def test_trilu_lower_one(self) -> None:
             [make_node("Trilu", ["x"], ["y"], upper=0)],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.INT32, (3, 1, 5))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.INT32, (3, 1, 5))]
+        )  # type: ignore
 
     def test_batch_norm_train(self) -> None:
         graph = self._make_graph(
@@ -7924,7 +8105,9 @@ def test_batch_norm_test(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.FLOAT, (3, 4, 5, 6, 7))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.FLOAT, (3, 4, 5, 6, 7))]
+        )  # type: ignore
 
     def test_batch_norm_test_no_dim(self) -> None:
         graph = self._make_graph(
@@ -7945,7 +8128,14 @@ def test_batch_norm_test_no_dim(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.FLOAT, (3, 4, None, None, None))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [
+                make_tensor_value_info(
+                    "out", TensorProto.FLOAT, (3, 4, None, None, None)
+                )
+            ],
+        )  # type: ignore
 
     def test_batch_norm_train_no_shape(self) -> None:
         graph = self._make_graph(
@@ -7981,13 +8171,17 @@ def test_nonzero(self) -> None:
             [make_node("NonZero", ["x"], ["out"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.INT64, (1, None))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.INT64, (1, None))]
+        )  # type: ignore
 
     def test_nonzero_no_shape(self) -> None:
         graph = self._make_graph(
             [("x", TensorProto.FLOAT, None)], [make_node("NonZero", ["x"], ["out"])], []
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.INT64, (None, None))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.INT64, (None, None))]
+        )  # type: ignore
 
     def test_nonzero_existing_dim_param(self) -> None:
         graph = self._make_graph(
@@ -7995,13 +8189,17 @@ def test_nonzero_existing_dim_param(self) -> None:
             [make_node("NonZero", ["x"], ["y"])],
             [make_tensor_value_info("y", TensorProto.INT64, (None, "NZ"))],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("y", TensorProto.INT64, (1, "NZ"))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("y", TensorProto.INT64, (1, "NZ"))]
+        )  # type: ignore
 
     def test_nonzero_scalar(self) -> None:
         graph = self._make_graph(
             [("x", TensorProto.FLOAT, ())], [make_node("NonZero", ["x"], ["out"])], []
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.INT64, (0, None))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.INT64, (0, None))]
+        )  # type: ignore
 
     def test_optional_construct_empty_tensor(self) -> None:
         tensor_type_proto = helper.make_tensor_type_proto(
@@ -8280,7 +8478,9 @@ def test_optional_sequence_get_element(self) -> None:
             ],
             [],
         )
-        self._assert_inferred(graph, [optional_val_info, sequence_val_into, output_val_into])  # type: ignore
+        self._assert_inferred(
+            graph, [optional_val_info, sequence_val_into, output_val_into]
+        )  # type: ignore
 
     def test_where_bfloat(self) -> None:
         graph = self._make_graph(
@@ -8292,7 +8492,9 @@ def test_where_bfloat(self) -> None:
             [make_node("Where", ["cond", "x", "y"], ["out"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("out", TensorProto.BFLOAT16, (10,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("out", TensorProto.BFLOAT16, (10,))]
+        )  # type: ignore
 
     def test_parse_data_with_unsupported_tensor_type(self) -> None:
         model = helper.make_model(
@@ -9111,7 +9313,9 @@ def test_dft_dft_length(
                             "dft_length", TensorProto.INT64, (), (dft_length,)
                         ),
                     ),
-                    make_node("DFT", ["input", "dft_length", "axis"], ["output"], **attributes),  # type: ignore[arg-type]
+                    make_node(
+                        "DFT", ["input", "dft_length", "axis"], ["output"], **attributes  # type: ignore[arg-type]
+                    ),
                 ]
                 value_infos = [
                     make_tensor_value_info("dft_length", TensorProto.INT64, ()),
@@ -9127,7 +9331,9 @@ def test_dft_dft_length(
                             "dft_length", TensorProto.INT64, (), (dft_length,)
                         ),
                     ),
-                    make_node("DFT", ["input", "dft_length", ""], ["output"], **attributes),  # type: ignore[arg-type]
+                    make_node(
+                        "DFT", ["input", "dft_length", ""], ["output"], **attributes  # type: ignore[arg-type]
+                    ),
                 ]
                 value_infos = [
                     make_tensor_value_info("dft_length", TensorProto.INT64, ())
@@ -9312,7 +9518,7 @@ def test_dft_dynamic_axis_onesided_dft_length_opset20(
                     ),
                 ),
                 make_node(
-                    "DFT", ["input", "dft_length", "axis"], ["output"], onesided=1
+                    "DFT", ["input", "dft_length", "axis"], ["output"], onesided=1  # type: ignore[arg-type]
                 ),
             ],
             [],
@@ -10132,7 +10338,9 @@ def test_compress_without_axis(self) -> None:
             [make_node("Compress", ["input", "condition"], ["output"])],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("output", TensorProto.INT64, (None,))])  # type: ignore
+        self._assert_inferred(
+            graph, [make_tensor_value_info("output", TensorProto.INT64, (None,))]
+        )  # type: ignore
 
     def test_compress_with_axis(self) -> None:
         graph = self._make_graph(
@@ -10143,7 +10351,10 @@ def test_compress_with_axis(self) -> None:
             [make_node("Compress", ["input", "condition"], ["output"], axis=-1)],
             [],
         )
-        self._assert_inferred(graph, [make_tensor_value_info("output", TensorProto.INT64, (2, "N", 3, None))])  # type: ignore
+        self._assert_inferred(
+            graph,
+            [make_tensor_value_info("output", TensorProto.INT64, (2, "N", 3, None))],
+        )  # type: ignore
 
     def test_check_type_when_schema_has_empty_io(self):
         input = """
@@ -10172,6 +10383,66 @@ def test_check_type_when_schema_has_empty_io(self):
             op_schema.name, op_schema.since_version, op_schema.domain
         )
 
+    def test_issue_layer_normalization_6187(self):
+        modeltxt = """
+        <
+        ir_version: 10,
+        opset_import: ["" : 17]
+        >
+        graph (float in0, float[2,7,8,1,3] in1, float[3,7] in2) => () {
+        out0, out1, out2 = LayerNormalization <epsilon: float = -841.058, stash_type: int = -940> (in0, in1, in2)
+        }
+        """
+        model = onnx.parser.parse_model(modeltxt)
+        with self.assertRaises(onnx.shape_inference.InferenceError):
+            onnx.checker.check_model(model, full_check=True)
+            onnx.shape_inference.infer_shapes(model)
+
+    def test_issue_conv_6180(self):
+        modeltxt = """
+        <
+        ir_version: 9,
+        opset_import: ["" : 11]
+        >
+        graph (float[7,6,1,5] in0, float in1, float[7,2,3,2,1] in2) => () {
+        out0 = Conv <auto_pad = "NOTSET", group = 1> (in0, in1, in2)
+        }
+        """
+        model = onnx.parser.parse_model(modeltxt)
+        with self.assertRaises(onnx.shape_inference.InferenceError):
+            onnx.checker.check_model(model, full_check=True)
+            onnx.shape_inference.infer_shapes(model)
+
+    def test_issue_gemm_6185(self):
+        modeltxt = """
+        <
+        ir_version: 10,
+        opset_import: ["" : 6]
+        >
+        graph (double[2,1] in0, double in1, double[2] in2) => () {
+        out0 = Gemm <alpha: float = 1, beta: float = -693.752, broadcast: int = -436, transB: int = 823> (in0, in1, in2)
+        }
+        """
+        model = onnx.parser.parse_model(modeltxt)
+        with self.assertRaises(onnx.checker.ValidationError):
+            onnx.checker.check_model(model, full_check=True)
+            onnx.shape_inference.infer_shapes(model)
+
+    def test_issue_stft_6186(self):
+        modeltxt = """
+        <
+        ir_version: 10,
+        opset_import: ["" : 17]
+        >
+        graph (float16[3] in0, int32[2] in1, float16[7,8,8,8] in2, int32[8,1,7,2] in3) => () {
+        out0 = STFT (in0, in1, in2, in3)
+        }
+        """
+        model = onnx.parser.parse_model(modeltxt)
+        with self.assertRaises(onnx.shape_inference.InferenceError):
+            onnx.checker.check_model(model, full_check=True)
+            onnx.shape_inference.infer_shapes(model)
+
 
 if __name__ == "__main__":
-    unittest.main()
+    unittest.main(verbosity=2)


Code review comments:
diff_hunk: @@ -105,6 +105,8 @@ struct InferenceContext {
   virtual const SparseTensorProto* getInputSparseData(size_t index) const = 0;
   // Gets the shape inputs computed by partial data propagation.
   virtual const TensorShapeProto* getSymbolicInput(size_t index) const = 0;
+  // To display a name the user can use to narrow its search.
+  virtual std::string getDisplayName() const = 0;
path: onnx/defs/shape_inference.h
text: @user1:
May be useful to provide a default implementation for backward compatibility (with other tools/implementations, like ORT). That way, they can add a custom implementation when they are ready.

@user1:
I mean even an empty string would be ok.

@author:
True.

@author:
done