<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_task(self, cor, name=None, finalizer=None, stop_timeout=1.0, parent=None):
 """Schedule a task to run on the background event loop. This method will start the given coroutine as a task and keep track of it so that it can be properly shutdown which the event loop is stopped. If parent is None, the task will be stopped by calling finalizer() inside the event loop and then awaiting the task. If finalizer is None then task.cancel() will be called to stop the task. If finalizer is specified, it is called with a single argument (self, this BackgroundTask). Finalizer can be a simple function, or any awaitable. If it is an awaitable it will be awaited. If parent is not None, it must be a BackgroundTask object previously created by a call to BackgroundEventLoop.add_task() and this task will be registered as a subtask of that task. It is that task's job then to cancel this task or otherwise stop it when it is stopped. This method is safe to call either from inside the event loop itself or from any other thread without fear of deadlock or race. Args: cor (coroutine or asyncio.Task):
 An asyncio Task or the coroutine that we should execute as a task. If a coroutine is given it is scheduled as a task in threadsafe manner automatically. name (str):
 The name of the task for pretty printing and debug purposes. If not specified, it defaults to the underlying asyncio task object instance name. finalizer (callable):
 An optional callable that should be invoked to cancel the task. If not specified, calling stop() will result in cancel() being called on the underlying task. stop_timeout (float):
 The maximum amount of time to wait for this task to stop when stop() is called in seconds. None indicates an unlimited amount of time. Default is 1. This is ignored if parent is not None. parent (BackgroundTask):
 A previously created task that will take responsibility for stopping this task when it is stopped. Returns: BackgroundTask: The BackgroundTask representing this task. """


        if self.stopping:
            raise LoopStoppingError("Cannot add task because loop is stopping")

        # Ensure the loop exists and is started
        self.start()

        if parent is not None and parent not in self.tasks:
            raise ArgumentError("Designated parent task {} is not registered".format(parent))

        task = BackgroundTask(cor, name, finalizer, stop_timeout, loop=self)
        if parent is None:
            self.tasks.add(task)
            self._logger.debug("Added primary task %s", task.name)
        else:
            parent.add_subtask(task)
            self._logger.debug("Added subtask %s to parent %s", task.name, parent.name)

        return task