def volume(items: _Iterable[int]) -> int:
    """
    Given an input shape, computes the volume or total number of elements contained
    by that shape. Note that an empty tensor will always have a volume of 0.
    """

    ret = 1 if len(items) >= 1 else 0
    for item in items:
        ret *= item
    return ret

    Given an input shape, computes the volume or total number of elements contained
    by that shape. Note that an empty tensor will always have a volume of 0.
    
coremltools/optimize/torch/_utils/graph_utils.py