<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_widget(path):
 """ Load custom widget for the form field """

    i = path.rfind('.')
    module, attr = path[:i], path[i + 1:]
    try:
        mod = import_module(module)
    except (ImportError, ValueError) as e:
        error_message = 'Error importing widget for BleachField %s: "%s"'
        raise ImproperlyConfigured(error_message % (path, e))

    try:
        cls = getattr(mod, attr)
    except AttributeError:
        raise ImproperlyConfigured(
            'Module "%s" does not define a "%s" widget' % (module, attr)
        )

    return cls