<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _copy_required(lib_path, copy_filt_func, copied_libs):
 """ Copy libraries required for files in `lib_path` to `lib_path` Augment `copied_libs` dictionary with any newly copied libraries, modifying `copied_libs` in-place - see Notes. This is one pass of ``copy_recurse`` Parameters lib_path : str Directory containing libraries copy_filt_func : None or callable, optional If None, copy any library that found libraries depend on. If callable, called on each library name; copy where ``copy_filt_func(libname)`` is True, don't copy otherwise copied_libs : dict See :func:`copy_recurse` for definition. Notes ----- If we need to copy another library, add that (``depended_lib_path``, ``dependings_dict``) to `copied_libs`. ``dependings_dict`` has (key, value) pairs of (``depending_lib_path``, ``install_name``). ``depending_lib_path`` will be the original (canonical) library name, not the copy in ``lib_path``. Sometimes we copy a library, that further depends on a library we have already copied. In this case update ``copied_libs[depended_lib]`` with the extra dependency (as well as fixing up the install names for the depending library). For example, imagine we've start with a lib path like this:: my_lib_path/ libA.dylib libB.dylib Our input `copied_libs` has keys ``/sys/libA.dylib``, ``/sys/libB.lib`` telling us we previously copied those guys from the ``/sys`` folder. On a first pass, we discover that ``libA.dylib`` depends on ``/sys/libC.dylib``, so we copy that. On a second pass, we discover now that ``libC.dylib`` also depends on ``/sys/libB.dylib``. `copied_libs` tells us that we already have a copy of ``/sys/libB.dylib``, so we fix our copy of `libC.dylib`` to point to ``my_lib_path/libB.dylib`` and add ``/sys/libC.dylib`` as a ``dependings_dict`` entry for ``copied_libs['/sys/libB.dylib']`` """

    # Paths will be prepended with `lib_path`
    lib_dict = tree_libs(lib_path)
    # Map library paths after copy ('copied') to path before copy ('orig')
    rp_lp = realpath(lib_path)
    copied2orig = dict((pjoin(rp_lp, basename(c)), c) for c in copied_libs)
    for required, requirings in lib_dict.items():
        if not copy_filt_func is None and not copy_filt_func(required):
            continue
        if required.startswith('@'):
            # May have been processed by us, or have some rpath, loader_path of
            # its own. Either way, leave alone
            continue
        # Requiring names may well be the copies in lib_path.  Replace the copy
        # names with the original names for entry into `copied_libs`
        procd_requirings = {}
        # Set requiring lib install names to point to local copy
        for requiring, orig_install_name in requirings.items():
            set_install_name(requiring,
                             orig_install_name,
                             '@loader_path/' + basename(required))
            # Make processed version of ``dependings_dict``
            mapped_requiring = copied2orig.get(requiring, requiring)
            procd_requirings[mapped_requiring] = orig_install_name
        if required in copied_libs:
            # Have copied this already, add any new requirings
            copied_libs[required].update(procd_requirings)
            continue
        # Haven't see this one before, add entry to copied_libs
        out_path = pjoin(lib_path, basename(required))
        if exists(out_path):
            raise DelocationError(out_path + ' already exists')
        shutil.copy(required, lib_path)
        copied2orig[out_path] = required
        copied_libs[required] = procd_requirings