def test_multi_functions_state_model(self):
        """
        Make sure multi-functions Core ML models support state.
        """

        @mb.function(
            input_specs=[mb.StateTensorSpec((3,), dtype=types.fp16)],
            opset_version=ct.target.iOS18,
        )
        def func(x):
            return mb.read_state(input=x, name="output")

        @mb.function(
            input_specs=[mb.StateTensorSpec((2,), dtype=types.fp16)],
            opset_version=ct.target.iOS18,
        )
        def func_1(y):
            return mb.read_state(input=y, name="output")

        prog = mil.Program()
        prog.add_function("main", func)
        prog.add_function("func_1", func_1)
        prog.export_as_multifunction = True

        mlmodel = _mil_convert(
            prog,
            convert_to="mlprogram",
            convert_from="milinternal",
            specification_version=_SPECIFICATION_VERSION_IOS_18,
            compute_units=ct.ComputeUnit.CPU_ONLY,
        )

        spec = mlmodel.get_spec()
        desc = spec.description
        assert len(desc.functions) == 2
        assert desc.functions[0].name == "main"
        assert len(desc.functions[0].state) == 1
        assert desc.functions[0].state[0].name == "x"
        assert desc.functions[1].name == "func_1"
        assert len(desc.functions[1].state) == 1
        assert desc.functions[1].state[0].name == "y"

        # main function is the default function
        self.verify_stateful_model(mlmodel, np.zeros((3,)))

        # save the mlmodel on disk, and load "main" and "func_1" separately
        package_path = tempfile.mkdtemp(suffix=".mlpackage")
        mlmodel.save(package_path)

        # test "main" function
        mlmodel_main = ct.models.MLModel(
            package_path, compute_units=ct.ComputeUnit.CPU_ONLY, function_name="main"
        )
        self.verify_stateful_model(mlmodel_main, np.zeros((3,)))

        # test "func_1" function
        mlmodel_func_1 = ct.models.MLModel(
            package_path, compute_units=ct.ComputeUnit.CPU_ONLY, function_name="func_1"
        )
        self.verify_stateful_model(mlmodel_func_1, np.zeros((2,)))

        # cleanup mlpackage
        shutil.rmtree(package_path)

        Make sure multi-functions Core ML models support state.
        
coremltools/converters/mil/backend/mil/test_load.py