<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_instance(name, cls='system', storage=None, storage_parameters=None, unsecure=None, *args, **kwargs):
 """ Get a cloud object storage instance. Args: name (str):
 File name, path or URL. cls (str):
 Type of class to instantiate. 'raw', 'buffered' or 'system'. storage (str):
 Storage name. storage_parameters (dict):
 Storage configuration parameters. Generally, client configuration and credentials. unsecure (bool):
 If True, disables TLS/SSL to improves transfer performance. But makes connection unsecure. Default to False. args, kwargs: Instance arguments Returns: pycosio._core.io_base.ObjectIOBase subclass: Instance """

    system_parameters = _system_parameters(
        unsecure=unsecure, storage_parameters=storage_parameters)

    # Gets storage information
    with _MOUNT_LOCK:
        for root in MOUNTED:
            if ((isinstance(root, Pattern) and root.match(name)) or
                    (not isinstance(root, Pattern) and
                     name.startswith(root))):
                info = MOUNTED[root]

                # Get stored storage parameters
                stored_parameters = info.get('system_parameters') or dict()
                if not system_parameters:
                    same_parameters = True
                    system_parameters = stored_parameters
                elif system_parameters == stored_parameters:
                    same_parameters = True
                else:
                    same_parameters = False
                    # Copy not specified parameters from default
                    system_parameters.update({
                        key: value for key, value in stored_parameters.items()
                        if key not in system_parameters})
                break

        # If not found, tries to mount before getting
        else:
            mount_info = mount(
                storage=storage, name=name, **system_parameters)
            info = mount_info[tuple(mount_info)[0]]
            same_parameters = True

    # Returns system class
    if cls == 'system':
        if same_parameters:
            return info['system_cached']
        else:
            return info['system'](
                roots=info['roots'], **system_parameters)

    # Returns other classes
    if same_parameters:
        if 'storage_parameters' not in system_parameters:
            system_parameters['storage_parameters'] = dict()
        system_parameters['storage_parameters'][
            'pycosio.system_cached'] = info['system_cached']

    kwargs.update(system_parameters)
    return info[cls](name=name, *args, **kwargs)