<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def iter_factories():
 """Iterate through all factories identified by the factory entrypoint. Yields: function: A function that accepts a :class:`.Specification` and returns a :class:`.PenaltyModel`. """

    # retrieve all of the factories with
    factories = (entry.load() for entry in iter_entry_points(FACTORY_ENTRYPOINT))

    # sort the factories from highest priority to lowest. Any factory with unknown priority
    # gets assigned priority -1000.
    for factory in sorted(factories, key=lambda f: getattr(f, 'priority', -1000), reverse=True):
        yield factory