def get_monomials(variables, degree):
if degree == -<NUM_LIT:1>:<EOL><INDENT>return []<EOL><DEDENT>if not variables:<EOL><INDENT>return [S.One]<EOL><DEDENT>else:<EOL><INDENT>_variables = variables[:]<EOL>_variables.insert(<NUM_LIT:0>, <NUM_LIT:1>)<EOL>ncmonomials = [S.One]<EOL>ncmonomials.extend(var for var in variables)<EOL>for var in variables:<EOL><INDENT>if not is_hermitian(var):<EOL><INDENT>ncmonomials.append(var.adjoint())<EOL><DEDENT><DEDENT>for _ in range(<NUM_LIT:1>, degree):<EOL><INDENT>temp = []<EOL>for var in _variables:<EOL><INDENT>for new_var in ncmonomials:<EOL><INDENT>temp.append(var * new_var)<EOL>if var != <NUM_LIT:1> and not is_hermitian(var):<EOL><INDENT>temp.append(var.adjoint() * new_var)<EOL><DEDENT><DEDENT><DEDENT>ncmonomials = unique(temp[:])<EOL><DEDENT>return ncmonomials<EOL><DEDENT>
Generates all noncommutative monomials up to a degree

    :param variables: The noncommutative variables to generate monomials from
    :type variables: list of :class:`sympy.physics.quantum.operator.Operator`
                     or
                     :class:`sympy.physics.quantum.operator.HermitianOperator`.
    :param degree: The maximum degree.
    :type degree: int.

    :returns: list of monomials.