<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_replication(self, source_db=None, target_db=None, repl_id=None, **kwargs):
 """ Creates a new replication task. :param source_db: Database object to replicate from. Can be either a ``CouchDatabase`` or ``CloudantDatabase`` instance. :param target_db: Database object to replicate to. Can be either a ``CouchDatabase`` or ``CloudantDatabase`` instance. :param str repl_id: Optional replication id. Generated internally if not explicitly set. :param dict user_ctx: Optional user to act as. Composed internally if not explicitly set. :param bool create_target: Specifies whether or not to create the target, if it does not already exist. :param bool continuous: If set to True then the replication will be continuous. :returns: Replication document as a Document instance """

        if source_db is None:
            raise CloudantReplicatorException(101)

        if target_db is None:
            raise CloudantReplicatorException(102)

        data = dict(
            _id=repl_id if repl_id else str(uuid.uuid4()),
            **kwargs
        )

        # replication source

        data['source'] = {'url': source_db.database_url}
        if source_db.admin_party:
            pass  # no credentials required
        elif source_db.client.is_iam_authenticated:
            data['source'].update({'auth': {
                'iam': {'api_key': source_db.client.r_session.get_api_key}
            }})
        else:
            data['source'].update({'headers': {
                'Authorization': source_db.creds['basic_auth']
            }})

        # replication target

        data['target'] = {'url': target_db.database_url}
        if target_db.admin_party:
            pass  # no credentials required
        elif target_db.client.is_iam_authenticated:
            data['target'].update({'auth': {
                'iam': {'api_key': target_db.client.r_session.get_api_key}
            }})
        else:
            data['target'].update({'headers': {
                'Authorization': target_db.creds['basic_auth']
            }})

        # add user context delegation

        if not data.get('user_ctx') and self.database.creds and \
            self.database.creds.get('user_ctx'):
            data['user_ctx'] = self.database.creds['user_ctx']

        return self.database.create_document(data, throw_on_exists=True)