def test_utils_randomize_weights():
        """
        Test ct.models.utils.randomize_weights method end to end
        """

        # Doing a lazy import because it imports `coremltools.converters.mil.mil.ops.tests.iOS18 import backends`
        # which brings dependencies on backends which shouldn't be needed for most tests in `test_passes.py`
        from coremltools.test.optimize.coreml.test_post_training_quantization import (
            get_test_model_and_data_complex,
        )

        model, inputs, torch_input_values, coreml_input_values = get_test_model_and_data_complex()
        torchmodel = torch.jit.trace(model, torch_input_values)
        mlmodel = ct.convert(
            torchmodel,
            inputs=inputs,
            convert_to="mlprogram",
            compute_precision=ct.precision.FLOAT32,
        )

        # randomize weights
        randomized_mlmodel = ct.models.utils.randomize_weights(mlmodel)

        # get before/after mil
        prog_before = mlmodel._mil_program
        prog_after = randomized_mlmodel._mil_program

        # check ops haven't changed
        assert get_op_types_in_program(prog_before) == get_op_types_in_program(prog_after)
        assert prog_before.find_ops(op_type="conv")[1].weight.op.op_type == "const"
        assert prog_after.find_ops(op_type="conv")[1].weight.op.op_type == "const"

        # check the weights have changed
        TestRandomizeWeights.assert_weights_changed(prog_before, prog_after)

        Test ct.models.utils.randomize_weights method end to end
        
coremltools/converters/mil/mil/passes/tests/test_passes.py