code: def test_doit_nested_MatrixExpr():
      X = ImmutableMatrix([[1, 2], [3, 4]])
      Y = ImmutableMatrix([[2, 3], [4, 5]])
      assert MatPow(MatMul(X, Y), 2).doit() == (X * Y) ** 2
      assert MatPow(MatAdd(X, Y), 2).doit() == (X + Y) ** 2
  
imports: from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.simplify.powsimp import powsimp
  from sympy.testing.pytest import raises
  from sympy.core.expr import unchanged
  from sympy.core import symbols, S
  from sympy.matrices import Identity, MatrixSymbol, ImmutableMatrix, ZeroMatrix, OneMatrix, Matrix
  from sympy.matrices.exceptions import NonSquareMatrixError
  from sympy.matrices.expressions import MatPow, MatAdd, MatMul
  from sympy.matrices.expressions.inverse import Inverse
  from sympy.matrices.expressions.matexpr import MatrixElement
label_desc: Use image node_id 9 for calling a global function with example usage: test_doit_nested_MatrixExpr() without return types