<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def duplicate_files(self):
        '''
        Search for duplicates of submission file uploads for this assignment.
        This includes the search in other course, whether inactive or not.
        Returns a list of lists, where each latter is a set of duplicate submissions
        with at least on of them for this assignment
        '''
        result=list()
        files = SubmissionFile.valid_ones.order_by('md5')

        for key, dup_group in groupby(files, lambda f: f.md5):
            file_list=[entry for entry in dup_group]
            if len(file_list)>1:
                for entry in file_list:
                    if entry.submissions.filter(assignment=self).count()>0:
                        result.append([key, file_list])
                        break
        return result