def greedy_by_size_memory_planning(sorted_graph: List[Tensor]):  # noqa: C901
    """
    based on the greedy-by-size algorithm for offset calculation described in
    the following paper:
        Yury Pisarchyk, Juhyun Lee,
        Efficient Memory Management for Deep Neural Net Inference,
        https://arxiv.org/abs/2001.03288
    """
    sorted_ops = []
    for node in sorted_graph:
        sorted_ops.extend(node.src_ops())
    tensor_usage_records = _make_tensor_usage_records(sorted_ops)

    return _greedy_by_size_memory_planning(sorted_graph, tensor_usage_records)
based on the greedy-by-size algorithm for offset calculation described in
the following paper:
Yury Pisarchyk, Juhyun Lee,
Efficient Memory Management for Deep Neural Net Inference,
https://arxiv.org/abs/2001.03288
python/aitemplate/compiler/transform/memory_planning.py