code: def test_list_datasets_by_task():
      dataset = "test_list_datasets_by_task"
      workspace_name = "other"
  
      all_datasets = dao.list_datasets(workspaces=[workspace_name])
      for ds in all_datasets:
          dao.delete_dataset(ds)
  
      created_text = dao.create_dataset(
          BaseDatasetDB(
              name=dataset + "_text",
              workspace=workspace_name,
              task=TaskType.text_classification,
          ),
      )
  
      created_token = dao.create_dataset(
          BaseDatasetDB(
              name=dataset + "_token",
              workspace=workspace_name,
              task=TaskType.token_classification,
          ),
      )
  
      assert len(dao.list_datasets()) == 0
      assert len(dao.list_datasets(workspaces=[workspace_name])) == 2
  
      datasets = dao.list_datasets(
          workspaces=[workspace_name],
          task2dataset_map={created_text.task: BaseDatasetDB},
      )
  
      assert len(datasets) == 1
      assert datasets[0].name == created_text.name
  
      datasets = dao.list_datasets(
          workspaces=[workspace_name],
          task2dataset_map={created_token.task: BaseDatasetDB},
      )
  
      assert len(datasets) == 1
      assert datasets[0].name == created_token.name
  
file_path: argilla/tests/unit/server/daos/test_datasets.py
imports: import pytest
  from argilla.server.commons.models import TaskType
  from argilla.server.daos.backend import GenericElasticEngineBackend
  from argilla.server.daos.datasets import DatasetsDAO
  from argilla.server.daos.models.datasets import BaseDatasetDB
  from argilla.server.daos.records import DatasetRecordsDAO
  from argilla.server.errors import ClosedDatasetError
label_desc: Use image node_id 2 for calling a global function with example usage: test_list_datasets_by_task() without return types