def test_get_weights_metadata_shared_weight():
        """
        Test the get_weights_metadata functionality for models with weight-sharing layers.
        """
        def _test_child_ops(child_ops):
            assert len(child_ops) == 2

            assert child_ops[0].name == "add_1"
            assert child_ops[0].op_type == "add"
            assert child_ops[0].params_name_mapping["y"] == "w_1"

            assert child_ops[1].name == "add_2"
            assert child_ops[1].op_type == "add"
            assert child_ops[1].params_name_mapping["y"] == "w_1"

        @mb.program(
            input_specs=[
                mb.TensorSpec(shape=(1, 30, 10, 10)),
                mb.TensorSpec(shape=(1, 30, 10, 10)),
            ],
        )
        def prog(x, y):
            shared_weight = mb.const(
                val=np.random.rand(1, 30, 10, 10).astype(np.float32), name="w_1"
            )
            x = mb.add(x=x, y=shared_weight, name="add_1")
            y = mb.add(x=y, y=shared_weight, name="add_2")
            return x, y

        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 len(ops_metadata_dict) == 1
        child_ops = ops_metadata_dict["w_1"].child_ops
        _test_child_ops(child_ops)

        Test the get_weights_metadata functionality for models with weight-sharing layers.
        
coremltools/test/optimize/coreml/test_post_training_quantization.py