def _create_name_sharing_dict(
    duplicate_weights: defaultdict[tuple[int, str, tuple], set[tuple[str, int]]], suffix: str = ""
) -> dict[tuple[str, int], str]:
    """Create a map mapping old initializer names to new initializer names.

    As different ONNX models may use the same initializer name but need to be mapped to a different new name,
    the map is actually from (old name, model id) to new name.

    Example of initializers with the same name that will need to be mapped to a different one:
    Model 1 with:
    /transformer/Constant_8_output_0 of datatype 1

    Model 2 with:
    /transformer/Constant_8_output_0 of datatype 7

    Args:
        duplicate_weights (`DefaultDict[Tuple[int, bytes]`):
            Map of duplicate weights

        suffix (`str`, defaults to `""`):
            Suffix to append to common name

    """
    name_sharing_dict: dict[tuple[str, int], str] = {}
    used_common_names: dict[str, int] = {}
    for duplicates in duplicate_weights.values():
        common_name, model_id = duplicates.pop()

        # this is needed in case two different groups of shared initializers may share the same name, for example
        # onnx::MatMul_2295 in the first model, and onnx::MatMul_2295 in the second model, although point to
        # different data
        used_common_names[common_name] = used_common_names.get(common_name, 0) + 1

        duplicates.add((common_name, model_id))
        for k in duplicates:
            assert k not in name_sharing_dict
            name_sharing_dict[k] = (
                f"{common_name}_{suffix}_{used_common_names[common_name]}" if suffix != "" else common_name
            )

    return name_sharing_dict
Create a map mapping old initializer names to new initializer names.

    As different ONNX models may use the same initializer name but need to be mapped to a different new name,
    the map is actually from (old name, model id) to new name.

    Example of initializers with the same name that will need to be mapped to a different one:
    Model 1 with:
    /transformer/Constant_8_output_0 of datatype 1

    Model 2 with:
    /transformer/Constant_8_output_0 of datatype 7

    Args:
        duplicate_weights (`DefaultDict[Tuple[int, bytes]`):
            Map of duplicate weights

        suffix (`str`, defaults to `""`):
            Suffix to append to common name

    
olive/passes/onnx/merge_decoders.py