code: def refine_MatMul(expr, assumptions):
      """
      >>> from sympy import MatrixSymbol, Q, assuming, refine
      >>> X = MatrixSymbol('X', 2, 2)
      >>> expr = X * X.T
      >>> print(expr)
      X*X.T
      >>> with assuming(Q.orthogonal(X)):
      ...     print(refine(expr))
      I
      """
      newargs = []
      exprargs = []
  
      for args in expr.args:
          if args.is_Matrix:
              exprargs.append(args)
          else:
              newargs.append(args)
  
      last = exprargs[0]
      for arg in exprargs[1:]:
          if arg == last.T and ask(Q.orthogonal(arg), assumptions):
              last = Identity(arg.shape[0])
          elif arg == last.conjugate() and ask(
              Q.unitary(arg), assumptions
          ):
              last = Identity(arg.shape[0])
          else:
              newargs.append(last)
              last = arg
      newargs.append(last)
  
      return MatMul(*newargs)
  
imports: from sympy.assumptions.ask import ask, Q
  from sympy.assumptions.refine import handlers_dict
  from sympy.core import Basic, sympify, S
  from sympy.core.mul import mul, Mul
  from sympy.core.numbers import Number, Integer
  from sympy.core.symbol import Dummy
  from sympy.functions import adjoint
  from sympy.strategies import rm_id, unpack, typed, flatten, exhaust, do_one, new
  from sympy.matrices.exceptions import NonInvertibleMatrixError
  from sympy.matrices.matrixbase import MatrixBase
  from sympy.utilities.exceptions import sympy_deprecation_warning
  from sympy.matrices.expressions._shape import validate_matmul_integer
  from .inverse import Inverse
  from .matexpr import MatrixExpr
  from .matpow import MatPow
  from .transpose import transpose
  from .permutation import PermutationMatrix
  from .special import ZeroMatrix, Identity, GenericIdentity, OneMatrix
label_desc: Use image node_id 11 for calling a global function with example usage: refine_MatMul(expr, assumptions) and returns: MatMul