def separate_scalar_factor(element):
coeff = <NUM_LIT:1.0><EOL>monomial = S.One<EOL>if isinstance(element, (int, float, complex)):<EOL><INDENT>coeff *= element<EOL>return monomial, coeff<EOL><DEDENT>for var in element.as_coeff_mul()[<NUM_LIT:1>]:<EOL><INDENT>if not (var.is_Number or var.is_imaginary):<EOL><INDENT>monomial = monomial * var<EOL><DEDENT>else:<EOL><INDENT>if var.is_Number:<EOL><INDENT>coeff = float(var)<EOL><DEDENT>else:<EOL><INDENT>coeff = <NUM_LIT> * coeff<EOL><DEDENT><DEDENT><DEDENT>coeff = float(element.as_coeff_mul()[<NUM_LIT:0>]) * coeff<EOL>return monomial, coeff<EOL>
Construct a monomial with the coefficient separated
    from an element in a polynomial.