<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_enrollments(self, course_id=None, usernames=None):
 """ List all course enrollments. Args: course_id (str, optional):
 If used enrollments will be filtered to the specified course id. usernames (list, optional):
 List of usernames to filter enrollments. Notes: - This method returns an iterator to avoid going through the entire pagination at once. - The :class:`Enrollments` instance returned for each generated item will not have any course details. Examples: Get all enrollments for a specific course id do_something(enrollment) Get all enrollments for a set of usernames do_something(enrollment) Returns: Generator with an instance of :class:`Enrollments` for each item. """

        params = {}
        if course_id is not None:
            params['course_id'] = course_id
        if usernames is not None and isinstance(usernames, list):
            params['username'] = ','.join(usernames)

        done = False
        while not done:
            enrollments, next_cursor = self._get_enrollments_list_page(params)
            for enrollment in enrollments:
                yield Enrollment(enrollment)

            if next_cursor:
                params['cursor'] = next_cursor
            else:
                done = True