def remove_ids(mul):
 (factor, mmul) = mul.as_coeff_mmul()
 result = rm_id((lambda x: (x.is_Identity is True)))(mmul)
 if (result != mmul):
  return newmul(factor, *result.args)
 else:
  return mul

def remove_ids ( mul ) : ( factor , mmul ) = mul . as_coeff_mmul ( ) result = rm_id ( ( lambda x : ( x . is_Identity is True ) ) ) ( mmul ) if ( result != mmul ) : return newmul ( factor , * result . args ) else : return mul
remove identities from a matmul this is a modified version of sympy .