<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def email_generator(names=None, domains=None, unique=False):
 """Creates a generator for generating email addresses. :arg names: list of names to use; defaults to ENGLISH_MONARCHS lowercased, ascii-fied, and stripped of whitespace :arg domains: list of domains to use; defaults to DOMAINS :arg unique: True if you want the username part of the email addresses to be unique :returns: generator Example:: from eadred.helpers import email_generator gen = email_generator() for i in range(50):
 mymodel = SomeModel(email=gen.next()) mymodel.save() Example 2: 'eadwig@example.net' 'henrybeauclerc@mail1.example.org' 'williamrufus@example.com' """

    if names is None:
        names = [name.encode('ascii', 'ignore').lower().replace(b' ', b'')
                 for name in ENGLISH_MONARCHS]
    if domains is None:
        domains = DOMAINS

    if unique:
        uniquifyer = lambda: str(next(_unique_counter))
    else:
        uniquifyer = lambda: ''

    while True:
        yield '{0}{1}@{2}'.format(
            random.choice(names), uniquifyer(), random.choice(domains))