<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_m2m_popup_field(cls, *args, **kwargs):
 """ generate m2m field related to class wait popup crud """

        kwargs['popup_name'] = cls.get_class_verbose_name()
        kwargs['permissions_required'] = cls.permissions_required
        if cls.template_name_m2m is not None:
            kwargs['template_name'] = cls.template_name_m2m
        return ManyToManyWidget('{}_popup_create'.format(cls.get_class_name()), *args, **kwargs)