<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(src, dst, src_is_storage, dst_is_storage):
 """ Copies file from source to destination Args: src (str or file-like object):
 Source file. dst (str or file-like object):
 Destination file. src_is_storage (bool):
 Source is storage. dst_is_storage (bool):
 Destination is storage. """

    # If both storage: Tries to perform same storage direct copy
    if src_is_storage and dst_is_storage:
        system_src = get_instance(src)
        system_dst = get_instance(dst)

        # Same storage copy
        if system_src is system_dst:

            # Checks if same file
            if system_src.relpath(src) == system_dst.relpath(dst):
                raise same_file_error(
                    "'%s' and '%s' are the same file" % (src, dst))

            # Tries to copy
            try:
                return system_dst.copy(src, dst)
            except (UnsupportedOperation, ObjectException):
                pass

        # Copy from compatible storage using "copy_from_<src_storage>" or
        # "copy_to_<src_storage>" method if any
        for caller, called, method in (
                (system_dst, system_src, 'copy_from_%s'),
                (system_src, system_dst, 'copy_to_%s')):
            if hasattr(caller, method % called.storage):
                try:
                    return getattr(caller, method % called.storage)(
                        src, dst, called)
                except (UnsupportedOperation, ObjectException):
                    continue

    # At least one storage object: copies streams
    with cos_open(src, 'rb') as fsrc:
        with cos_open(dst, 'wb') as fdst:

            # Get stream buffer size
            for stream in (fsrc, fdst):
                try:
                    buffer_size = getattr(stream, '_buffer_size')
                    break
                except AttributeError:
                    continue
            else:
                buffer_size = COPY_BUFSIZE

            # Read and write
            copyfileobj(fsrc, fdst, buffer_size)