def _leaf_ref_to_chunk_clones_from_clone_ops(extent_id: int, clone_ops: Iterable[_CloneOp]):
    'As per `_leaf_extent_id_to_clone_ops`, this computes interval overlaps'
    active_ops: Dict[(_CloneExtentRef, _CloneOp)] = {}
    leaf_ref_to_chunk_clones = defaultdict(list)
    for op in sorted(clone_ops):
        if (op.action is _CloneOp.POP):
            pushed_op = active_ops.pop(op.ref)
            assert (pushed_op.ref is op.ref)
            assert (id(op.ref.extent) == extent_id)
            assert (pushed_op.pos == op.ref.offset)
            assert ((pushed_op.pos + op.ref.clone.length) == op.pos)
            for clone_op in active_ops.values():
                assert (op.ref.extent is clone_op.ref.extent)
                bigger_offset = max(clone_op.ref.offset, op.ref.offset)
                leaf_ref_to_chunk_clones[op.ref].append(ChunkClone(offset=bigger_offset, clone=Clone(inode_id=clone_op.ref.clone.inode_id, offset=(clone_op.ref.clone.offset + (bigger_offset - clone_op.ref.offset)), length=(op.pos - bigger_offset))))
                leaf_ref_to_chunk_clones[clone_op.ref].append(ChunkClone(offset=bigger_offset, clone=Clone(inode_id=op.ref.clone.inode_id, offset=(op.ref.clone.offset + (bigger_offset - op.ref.offset)), length=(op.pos - bigger_offset))))
        elif (op.action == _CloneOp.PUSH):
            assert (op.ref not in active_ops)
            active_ops[op.ref] = op
        else:
            raise AssertionError(op)
    return leaf_ref_to_chunk_clones
As per `_leaf_extent_id_to_clone_ops`, this computes interval overlaps
def _leaf_ref_to_chunk_clones_from_clone_ops(extent_id: int, clone_ops: Iterable[_CloneOp]):
    
    active_ops: Dict[(_CloneExtentRef, _CloneOp)] = {}
    leaf_ref_to_chunk_clones = defaultdict(list)
    for op in sorted(clone_ops):
        if (op.action is _CloneOp.POP):
            pushed_op = active_ops.pop(op.ref)
            assert (pushed_op.ref is op.ref)
            assert (id(op.ref.extent) == extent_id)
            assert (pushed_op.pos == op.ref.offset)
            assert ((pushed_op.pos + op.ref.clone.length) == op.pos)
            for clone_op in active_ops.values():
                assert (op.ref.extent is clone_op.ref.extent)
                bigger_offset = max(clone_op.ref.offset, op.ref.offset)
                leaf_ref_to_chunk_clones[op.ref].append(ChunkClone(offset=bigger_offset, clone=Clone(inode_id=clone_op.ref.clone.inode_id, offset=(clone_op.ref.clone.offset + (bigger_offset - clone_op.ref.offset)), length=(op.pos - bigger_offset))))
                leaf_ref_to_chunk_clones[clone_op.ref].append(ChunkClone(offset=bigger_offset, clone=Clone(inode_id=op.ref.clone.inode_id, offset=(op.ref.clone.offset + (bigger_offset - op.ref.offset)), length=(op.pos - bigger_offset))))
        elif (op.action == _CloneOp.PUSH):
            assert (op.ref not in active_ops)
            active_ops[op.ref] = op
        else:
            raise AssertionError(op)
    return leaf_ref_to_chunk_clones