def test_get_weights_metadata_op_var_different_name():
        """
        For several rare corner cases, the const var and op have different names.
        Test that the API is correctly using the op's name.
        """
        @mb.program(
            input_specs=[
                mb.TensorSpec(shape=(1, 30, 10, 10)),
            ],
        )
        def prog(x):
            shared_weight = mb.const(
                val=np.random.rand(1, 30, 10, 10).astype(np.float32), name="w_1"
            )
            shared_weight.name = "w_1_new"
            x = mb.add(x=x, y=shared_weight, name="add_1")
            return x

        mlmodel = ct.convert(
            prog,
            convert_to="mlprogram",
            compute_precision=ct.precision.FLOAT32,
        )

        ops_metadata_dict = ct.optimize.coreml.get_weights_metadata(
            mlmodel,
            weight_threshold=100,
        )
        assert "w_1" in ops_metadata_dict
        assert ops_metadata_dict["w_1"].child_ops[0].params_name_mapping["y"] == "w_1"

        For several rare corner cases, the const var and op have different names.
        Test that the API is correctly using the op's name.
        
coremltools/test/optimize/coreml/test_post_training_quantization.py