def METHOD_NAME(mul):
    """Remove Identities from a MatMul
    This is a modified version of diofant.core.strategies.rm_id.
    This is necesssary because MatMul may contain both MatrixExprs and Exprs
    as args.
    See Also
    ========
    diofant.core.strategies.rm_id
    """
    # Separate Exprs from MatrixExprs in args
    factor, mmul = mul.as_coeff_mmul()
    # Apply standard rm_id for MatMuls
    result = rm_id(lambda x: x.is_Identity is True)(mmul)
    if result != mmul:
        return newmul(factor, *result.args)  # Recombine and return
    return mul