code: def _is_diagonalizable(M, reals_only=False, **kwargs):
      """Returns ``True`` if a matrix is diagonalizable.
  
      Parameters
      ==========
  
      reals_only : bool, optional
          If ``True``, it tests whether the matrix can be diagonalized
          to contain only real numbers on the diagonal.
  
  
          If ``False``, it tests whether the matrix can be diagonalized
          at all, even with numbers that may not be real.
  
      Examples
      ========
  
      Example of a diagonalizable matrix:
  
      >>> from sympy import Matrix
      >>> M = Matrix([[1, 2, 0], [0, 3, 0], [2, -4, 2]])
      >>> M.is_diagonalizable()
      True
  
      Example of a non-diagonalizable matrix:
  
      >>> M = Matrix([[0, 1], [0, 0]])
      >>> M.is_diagonalizable()
      False
  
      Example of a matrix that is diagonalized in terms of non-real entries:
  
      >>> M = Matrix([[0, 1], [-1, 0]])
      >>> M.is_diagonalizable(reals_only=False)
      True
      >>> M.is_diagonalizable(reals_only=True)
      False
  
      See Also
      ========
  
      sympy.matrices.matrixbase.MatrixBase.is_diagonal
      diagonalize
      """
      if not M.is_square:
          return False
  
      if all(e.is_real for e in M) and M.is_symmetric():
          return True
  
      if all(e.is_complex for e in M) and M.is_hermitian:
          return True
  
      return _is_diagonalizable_with_eigen(M, reals_only=reals_only)[0]
  
imports: from types import FunctionType
  from collections import Counter
  from mpmath import mp, workprec
  from mpmath.libmp.libmpf import prec_to_dps
  from sympy.core.sorting import default_sort_key
  from sympy.core.evalf import DEFAULT_MAXPREC, PrecisionExhausted
  from sympy.core.logic import fuzzy_and, fuzzy_or
  from sympy.core.numbers import Float
  from sympy.core.sympify import _sympify
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.polys import roots, CRootOf, ZZ, QQ, EX
  from sympy.polys.matrices import DomainMatrix
  from sympy.polys.matrices.eigen import dom_eigenvects, dom_eigenvects_to_sympy
  from sympy.polys.polytools import gcd
  from .exceptions import MatrixError, NonSquareMatrixError
  from .determinant import _find_reasonable_pivot
  from .utilities import _iszero, _simplify
label_desc: Use image node_id 12 for calling a global function with example usage: _is_diagonalizable(M, reals_only) and returns: _is_diagonalizable_with_eigen, False, True, True