<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_backreferences(context, relationship=None, as_brains=None):
 """Return all objects which use a UIDReferenceField to reference context. :param context: The object which is the target of references. :param relationship: The relationship name of the UIDReferenceField. :param as_brains: Requests that this function returns only catalog brains. as_brains can only be used if a relationship has been specified. This function can be called with or without specifying a relationship. - If a relationship is provided, the return value will be a list of items which reference the context using the provided relationship. If relationship is provided, then you can request that the backrefs should be returned as catalog brains. If you do not specify as_brains, the raw list of UIDs will be returned. - If the relationship is not provided, then the entire set of backreferences to the context object is returned (by reference) as a dictionary. This value can then be modified in-place, to edit the stored backreferences. """


    instance = context.aq_base
    raw_backrefs = get_storage(instance)

    if not relationship:
        assert not as_brains, "You cannot use as_brains with no relationship"
        return raw_backrefs

    backrefs = list(raw_backrefs.get(relationship, []))
    if not backrefs:
        return []

    if not as_brains:
        return backrefs

    cat = _get_catalog_for_uid(backrefs[0])
    return cat(UID=backrefs)