def METHOD_NAME(month: int, year: int, include_extra: bool, filename: str):
    with open(filename, "w", encoding="utf-8") as out_file:
        writer = csv.writer(out_file)
        headers = ["Username", "Project Name", "Form Title", "No. of submissions"]
        form_fields = [
            "id",
            "project__name",
            "project__organization__username",
            "title",
        ]
        if include_extra:
            headers += ["Is Organization", "Organization Created By", "User last login"]
            form_fields += ["project__organization__last_login"]
        writer.writerow(headers)
        _, last_day = calendar.monthrange(year, month)
        date_obj = timezone.make_aware(datetime(year, month, last_day), timezone.utc)
        forms = XForm.objects.filter(
            Q(deleted_at__isnull=True) | Q(deleted_at__gt=date_obj),
            date_created__lte=date_obj,
        ).values(*form_fields)
        with use_master:
            for form in forms:
                instance_count = Instance.objects.filter(
                    Q(deleted_at__isnull=True) | Q(deleted_at__gt=date_obj),
                    xform_id=form.get("id"),
                    date_created__lte=date_obj,
                ).count()
                row = [
                    form.get("project__organization__username"),
                    form.get("project__name"),
                    form.get("title"),
                    instance_count,
                ]
                if include_extra:
                    user = User.objects.get(
                        username=form.get("project__organization__username")
                    )
                    is_org = is_organization(user.profile)
                    if is_org:
                        created_by = OrganizationProfile.objects.get(
                            user=user
                        ).creator.username
                    else:
                        created_by = "N/A"
                    row += [
                        is_org,
                        created_by,
                        form.get("project__organization__last_login"),
                    ]
                writer.writerow(row)