def _make_dynamic_optional(
        cls, dag: OnnxDAG, weights: dict[str, "NDArray"], name: str, config: type[BasePassConfig]
    ):
        """Make the input dynamic and optional."""
        if "quant" in name:
            # dynamic shape not supported for quantized modules
            # cannot have empty tensor as default values, so create default initializers of the same shape
            # scales must be zero to make the dequantized weights zero
            # quant weight and zeros points also made zero to be clean and consistent
            if config.optional_inputs:
                initializer_proto = onnx.numpy_helper.from_array(np.zeros_like(weights[name]), name)
                dag.add_initializer(initializer_proto, 0, keep_input=True)

            return

        # lora r dimension index
        dim_idx = 1 if "lora_A" in name else 0

        # make the input dynamic
        if config.dynamic_lora_r:
            dag.make_input_dim_dynamic(name, dim_idx, "lora_r")

        # create default initializer with the lora_r dimension set to 0
        if config.optional_inputs:
            shape = list(weights[name].shape)
            shape[dim_idx] = 0
            initializer_proto = onnx.numpy_helper.from_array(np.zeros(shape, dtype=weights[name].dtype), name)
            dag.add_initializer(initializer_proto, 0, keep_input=True)
Make the input dynamic and optional.
olive/passes/onnx/extract_adapters.py