def METHOD_NAME(self):
    data = self.cleaned_data['similar_groups'].splitlines()
    groups = []
    submissions_qs = Submission.objects.filter(
        problem_instance__contest=self.contest
    ).select_related('user', 'problem_instance')
    for line in data:
        matches = [m.groupdict() for m in similarity_pair_re.finditer(line)]
        if len(matches) < 2:
            if line.strip():
                raise ValidationError(
                    _("Can't parse nonempty line:\n%(line)s") % dict(line=line)
                )
            else:
                continue
        matched_submissions = []
        for match in matches:
            try:
                submission = submissions_qs.get(id=match['submission_id'])
            except Submission.DoesNotExist:
                raise ValidationError(
                    _("Submission %(id)s does not exists in line: %(line)s")
                    % dict(id=match['submission_id'], line=line)
                )
            if submission.user is None:
                raise ValidationError(
                    _(
                        "You can't say that this guy cooperated with model"
                        " solution author.... It's ridiculous! "
                        "In line: %(line)s"
                    )
                    % dict(line=line)
                )
            if submission.user.username != match['username']:
                raise ValidationError(
                    _(
                        "Submission's %(id)s incorrect author:\n"
                        "Expected: %(expected)s, but got %(given)s"
                        " in line %(line)s."
                        % dict(
                            id=match['submission_id'],
                            expected=submission.user.username,
                            given=match['username'],
                            line=line,
                        )
                    )
                )
            matched_submissions.append(submission)
        groups.append(tuple(matched_submissions))
    if not groups:
        raise ValidationError(_("No group found in given data."))
    return groups