def _leaf_extent_id_to_clone_ops(ids_and_extents: Iterable[Tuple[(InodeID, Extent)]]):
    '\n    To collect the parts of a Chunk that are cloned, we will run a variation\n    on the standard interval-overlap algorithm.  We first sort the starts &\n    ends of each interval, and then do a sequential scan that uses starts to\n    add, and ends to remove, a tracking object from a "current intervals"\n    structure.\n\n    This function simply prepares the set of interval starts & ends for each\n    InodeID, the computation is in `_leaf_ref_to_chunk_clones_from_clone_ops`.\n    '
    leaf_extent_id_to_clone_ops = defaultdict(list)
    for (ino_id, extent) in ids_and_extents:
        file_offset = 0
        for (leaf_idx, (offset, length, leaf_extent)) in enumerate(extent.gen_trimmed_leaves()):
            ref = _CloneExtentRef(clone=Clone(inode_id=ino_id, offset=file_offset, length=length), extent=leaf_extent, offset=offset, leaf_idx=leaf_idx)
            leaf_extent_id_to_clone_ops[id(leaf_extent)].extend([_CloneOp(pos=offset, action=_CloneOp.PUSH, ref=ref), _CloneOp(pos=(offset + length), action=_CloneOp.POP, ref=ref)])
            file_offset += length
    return leaf_extent_id_to_clone_ops
To collect the parts of a Chunk that are cloned, we will run a variation
on the standard interval-overlap algorithm.  We first sort the starts &
ends of each interval, and then do a sequential scan that uses starts to
add, and ends to remove, a tracking object from a "current intervals"
structure.

This function simply prepares the set of interval starts & ends for each
InodeID, the computation is in `_leaf_ref_to_chunk_clones_from_clone_ops`.
def _leaf_extent_id_to_clone_ops(ids_and_extents: Iterable[Tuple[(InodeID, Extent)]]):
    '\n    To collect the parts of a Chunk that are cloned, we will run a variation\n    on the standard interval-overlap algorithm.  We first sort the starts &\n    ends of each interval, and then do a sequential scan that uses starts to\n    add, and ends to remove, a tracking object from a "current intervals"\n    structure.\n\n    This function simply prepares the set of interval starts & ends for each\n    InodeID, the computation is in `_leaf_ref_to_chunk_clones_from_clone_ops`.\n    '
    leaf_extent_id_to_clone_ops = defaultdict(list)
    for (ino_id, extent) in ids_and_extents:
        file_offset = 0
        for (leaf_idx, (offset, length, leaf_extent)) in enumerate(extent.gen_trimmed_leaves()):
            ref = _CloneExtentRef(clone=Clone(inode_id=ino_id, offset=file_offset, length=length), extent=leaf_extent, offset=offset, leaf_idx=leaf_idx)
            leaf_extent_id_to_clone_ops[id(leaf_extent)].extend([_CloneOp(pos=offset, action=_CloneOp.PUSH, ref=ref), _CloneOp(pos=(offset + length), action=_CloneOp.POP, ref=ref)])
            file_offset += length
    return leaf_extent_id_to_clone_ops