code: def _simplify_matrix(M):
      """Return a simplified copy of the matrix M"""
      assert isinstance(M, (Matrix, ImmutableMatrix))
      Mnew = M.as_mutable()  # makes a copy if mutable
      Mnew.simplify()
      if isinstance(M, ImmutableMatrix):
          Mnew = Mnew.as_immutable()
      return Mnew
  
label_desc: Use image node_id 1 for calling a global function with example usage: _simplify_matrix(M) and returns: Mnew