def merge_subsamplings(subsampling, other):
    """Merge indices of sub-samplings, removing duplicates and sorting indices.

    Args:
        subsampling ([int] or None): Sub-sampling indices for use in a BackPACK
            extension as ``subsampling`` argument.
        other ([int] or None): Sub-sampling indices for use in a BackPACK
            extension as ``subsampling`` argument.

    Returns:
        [int]: Indices corresponding to the merged sub-samplings.
    """
    if subsampling is None or other is None:
        merged = None
    else:
        merged = sorted(set(subsampling).union(set(other)))

    return merged