code: def task_completed(task_id):
      
  
      tasks = get_tasks(task_id=task_id)
      completed_states = ('TASK_FINISHED',
                          'TASK_FAILED',
                          'TASK_KILLED',
                          'TASK_LOST',
                          'TASK_ERROR')
  
      for task in tasks:
          if task['state'] in completed_states:
              return True
  
      return False
docs: Check whether a task has completed.
  
          :param task_id: task ID
          :type task_id: str
  
          :return: True if completed, False otherwise
          :rtype: bool