code: def assemble_sparse_matrix(subtree: dict) -> scipy.sparse.spmatrix:
      
      matrix_class = getattr(scipy.sparse, "%s_matrix" % subtree["format"])
      if subtree["format"] in ("csr", "csc"):
          indptr = subtree["data"][2]
          if indptr[-1] != subtree["data"][0].shape[0]:
              # indptr is diff-ed
              subtree["data"][2] = indptr.cumsum()
      matrix = matrix_class(tuple(subtree["data"]), shape=subtree["shape"])
      return matrix
docs: Transform a dictionary with "shape", "format" and "data" into the \
      :mod:`scipy.sparse` matrix. \
      Opposite to :func:`disassemble_sparse_matrix()`.
  
      :param subtree: :class:`dict` which describes the :mod:`scipy.sparse` \
                      matrix.
      :return: :mod:`scipy.sparse` matrix of the specified format.