def blockcut(expr, rowsizes, colsizes):

    rowbounds = bounds(rowsizes)
    colbounds = bounds(colsizes)
    return BlockMatrix([[MatrixSlice(expr, rowbound, colbound)
                         for colbound in colbounds]
                         for rowbound in rowbounds])
Cut a matrix expression into Blocks
dataset/ETHPy150Open sympy/sympy/sympy/matrices/expressions/blockmatrix.py/blockcut