def test_invalid_state_shape_out(self, float32_buffer_model):
        """
        The conversion should error out if the provided StateType has
        a different shape than the registered buffer.
        """
        with pytest.raises(
            ValueError,
            match="StateType shape \(2,\) must match the torch buffer shape \(3,\)",
        ):
            prog = ct.convert(
                float32_buffer_model,
                inputs=[
                    ct.TensorType(shape=(3,)),
                ],
                states=[
                    ct.StateType(
                        wrapped_type=ct.TensorType(
                            shape=(2,),
                        ),
                        name="state",
                    ),
                ],
                minimum_deployment_target=ct.target.iOS18,
                compute_precision=ct.precision.FLOAT32,
                convert_to="milinternal",
            )

        The conversion should error out if the provided StateType has
        a different shape than the registered buffer.
        
coremltools/converters/mil/frontend/torch/test/test_torch_stateful_model.py