code: def _cholesky_sparse(M, hermitian=True):
      """
      Returns the Cholesky decomposition L of a matrix A
      such that L * L.T = A
  
      A must be a square, symmetric, positive-definite
      and non-singular matrix
  
      Examples
      ========
  
      >>> from sympy import SparseMatrix
      >>> A = SparseMatrix(((25,15,-5),(15,18,0),(-5,0,11)))
      >>> A.cholesky()
      Matrix([
      [ 5, 0, 0],
      [ 3, 3, 0],
      [-1, 1, 3]])
      >>> A.cholesky() * A.cholesky().T == A
      True
  
      The matrix can have complex entries:
  
      >>> from sympy import I
      >>> A = SparseMatrix(((9, 3*I), (-3*I, 5)))
      >>> A.cholesky()
      Matrix([
      [ 3, 0],
      [-I, 2]])
      >>> A.cholesky() * A.cholesky().H
      Matrix([
      [   9, 3*I],
      [-3*I,   5]])
  
      Non-hermitian Cholesky-type decomposition may be useful when the
      matrix is not positive-definite.
  
      >>> A = SparseMatrix([[1, 2], [2, 1]])
      >>> L = A.cholesky(hermitian=False)
      >>> L
      Matrix([
      [1,         0],
      [2, sqrt(3)*I]])
      >>> L*L.T == A
      True
  
      See Also
      ========
  
      sympy.matrices.sparse.SparseMatrix.LDLdecomposition
      sympy.matrices.matrixbase.MatrixBase.LUdecomposition
      QRdecomposition
      """
  
      from .dense import MutableDenseMatrix
  
      if not M.is_square:
          raise NonSquareMatrixError("Matrix must be square.")
      if hermitian and not M.is_hermitian:
          raise ValueError("Matrix must be Hermitian.")
      if not hermitian and not M.is_symmetric():
          raise ValueError("Matrix must be symmetric.")
  
      dps = _get_intermediate_simp(expand_mul, expand_mul)
      Crowstruc = M.row_structure_symbolic_cholesky()
      C = MutableDenseMatrix.zeros(M.rows)
  
      for i in range(len(Crowstruc)):
          for j in Crowstruc[i]:
              if i != j:
                  C[i, j] = M[i, j]
                  summ = 0
  
                  for p1 in Crowstruc[i]:
                      if p1 < j:
                          for p2 in Crowstruc[j]:
                              if p2 < j:
                                  if p1 == p2:
                                      if hermitian:
                                          summ += (
                                              C[i, p1]
                                              * C[j, p1].conjugate()
                                          )
                                      else:
                                          summ += C[i, p1] * C[j, p1]
                              else:
                                  break
                          else:
                              break
  
                  C[i, j] = dps((C[i, j] - summ) / C[j, j])
  
              else:  # i == j
                  C[j, j] = M[j, j]
                  summ = 0
  
                  for k in Crowstruc[j]:
                      if k < j:
                          if hermitian:
                              summ += C[j, k] * C[j, k].conjugate()
                          else:
                              summ += C[j, k] ** 2
                      else:
                          break
  
                  Cjj2 = dps(C[j, j] - summ)
  
                  if hermitian and Cjj2.is_positive is False:
                      raise NonPositiveDefiniteMatrixError(
                          "Matrix must be positive-definite"
                      )
  
                  C[j, j] = sqrt(Cjj2)
  
      return M._new(C)
  
imports: import copy
  from sympy.core import S
  from sympy.core.function import expand_mul
  from sympy.functions.elementary.miscellaneous import Min, sqrt
  from sympy.functions.elementary.complexes import sign
  from .exceptions import NonSquareMatrixError, NonPositiveDefiniteMatrixError
  from .utilities import _get_intermediate_simp, _iszero
  from .determinant import _find_reasonable_pivot_naive
label_desc: Use image node_id 5 for calling a global function with example usage: _cholesky_sparse(M, hermitian) and returns: M