code: def _berkowitz_vector(M):
      """Run the Berkowitz algorithm and return a vector whose entries
      are the coefficients of the characteristic polynomial of ``M``.
  
      Given N x N matrix, efficiently compute
      coefficients of characteristic polynomials of ``M``
      without division in the ground domain.
  
      This method is particularly useful for computing determinant,
      principal minors and characteristic polynomial when ``M``
      has complicated coefficients e.g. polynomials. Semi-direct
      usage of this algorithm is also important in computing
      efficiently sub-resultant PRS.
  
      Assuming that M is a square matrix of dimension N x N and
      I is N x N identity matrix, then the Berkowitz vector is
      an N x 1 vector whose entries are coefficients of the
      polynomial
  
                      charpoly(M) = det(t*I - M)
  
      As a consequence, all polynomials generated by Berkowitz
      algorithm are monic.
  
      For more information on the implemented algorithm refer to:
  
      [1] S.J. Berkowitz, On computing the determinant in small
          parallel time using a small number of processors, ACM,
          Information Processing Letters 18, 1984, pp. 147-150
  
      [2] M. Keber, Division-Free computation of sub-resultants
          using Bezout matrices, Tech. Report MPI-I-2006-1-006,
          Saarbrucken, 2006
      """
  
      # handle the trivial cases
      if M.rows == 0 and M.cols == 0:
          return M._new(1, 1, [M.one])
      elif M.rows == 1 and M.cols == 1:
          return M._new(2, 1, [M.one, -M[0, 0]])
  
      submat, toeplitz = _berkowitz_toeplitz_matrix(M)
  
      return toeplitz.multiply(
          _berkowitz_vector(submat), dotprodsimp=None
      )
  
imports: from types import FunctionType
  from sympy.core.cache import cacheit
  from sympy.core.numbers import Float, Integer
  from sympy.core.singleton import S
  from sympy.core.symbol import uniquely_named_symbol
  from sympy.core.mul import Mul
  from sympy.polys import PurePoly, cancel
  from sympy.functions.combinatorial.numbers import nC
  from sympy.polys.matrices.domainmatrix import DomainMatrix
  from sympy.polys.matrices.ddm import DDM
  from .exceptions import NonSquareMatrixError
  from .utilities import _get_intermediate_simp, _get_intermediate_simp_bool, _iszero, _is_zero_after_expand_mul, _dotprodsimp, _simplify
label_desc: Use image node_id 4 for calling a global function with example usage: _berkowitz_vector(M) and returns: toeplitz, M, M