class_docstr: Datasets DAO
class_docstr_tok: ["Datasets","DAO"]
code: def list_datasets(
      self,
      workspaces: List[str] = None,
      task2dataset_map: Dict[str, Type[DatasetDB]] = None,
      name: Optional[str] = None,
  ) -> List[DatasetDB]:
      if not workspaces:
          return []
  
      query = BaseDatasetsQuery(
          workspaces=workspaces,
          tasks=[task for task in task2dataset_map]
          if task2dataset_map
          else None,
          name=name,
      )
  
      docs = self._es.list_datasets(query)
      task2dataset_map = task2dataset_map or {}
      return [
          self._es_doc_to_instance(
              doc=doc,
              ds_class=task2dataset_map.get(doc["task"], BaseDatasetDB),
          )
          for doc in docs
      ]
  
imports: import json
  from typing import Any, Dict, List, Optional, Type
  from fastapi import Depends
  from argilla.server.daos.backend import BaseDatasetsQuery, GenericElasticEngineBackend
  from argilla.server.daos.models.datasets import BaseDatasetDB, BaseDatasetSettingsDB, DatasetDB, DatasetSettingsDB, EmbeddingsConfig
  from argilla.server.daos.records import DatasetRecordsDAO
  from argilla.server.errors import WrongTaskError
label_desc: Use image node_id 4 for calling the DatasetsDAO obj's underlying member method code with example usage: obj.list_datasets(workspaces, task2dataset_map, name) and returns: unknown, list