<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_widget_template(self, field_name, field):
 """ Returns the optional widget template to use when rendering the widget for a form field. Preference of template selection: 1. Template from `widget_template_overrides` selected by field name 2. Template from `widget_template_overrides` selected by widget class By default, returns `None` which means "use Django's default widget template". :param field_name: The field name to select a widget template for. :param field: `Field` instance to return a widget template. :return: Template name to use when rendering the widget or `None` """

        templates = self.widget_template_overrides or {}

        template_name = templates.get(field_name, None)
        if template_name:
            return template_name

        template_name = templates.get(field.widget.__class__, None)
        if template_name:
            return template_name

        return None