human
Complete the below
def group_albums(session):

    ''''A pipeline stage that groups the items of each task into albums
    using their metadata.
    Groups are identified using their artist and album fields. The
    pipeline stage emits new album tasks for each discovered group.'
    '''
 ... Give me a the Python code you requested?
assistant
#Here is the Python code you requested.
    def group(item):
        return ((item.albumartist or item.artist), item.album)
    task = None
    while True:
        task = (yield task)
        if task.skip:
            continue
        tasks = []
        sorted_items = sorted(task.items, key=group)
        for (_, items) in itertools.groupby(sorted_items, group):
            items = list(items)
            task = ImportTask(task.toppath, [i.path for i in items], items)
            tasks += task.handle_created(session)
        tasks.append(SentinelImportTask(task.toppath, task.paths))
        task = pipeline.multiple(tasks)