def get_datasets_by_name(
        self,
        dataset_name: str,
        shared: Optional[bool] = False,
    ) -> List[DatasetData]:
        """Fetches datasets by name.

        There can be multiple datasets with the same name accessible to the current
        user. This can happen if either:
        * A dataset has been explicitly shared with the user
        * The user has access to team datasets
        The `shared` flag controls whether these datasets are returned.

        Args:
            dataset_name:
                Name of the target dataset.
            shared:
                * If False (default), returns only datasets owned by the user. In this
                case at most one dataset will be returned.
                * If True, returns datasets which have been shared with the user,
                including team datasets. Excludes user's own datasets. Can return
                multiple datasets.
                * If None, returns all datasets the users has access to. Can return
                multiple datasets.

        Returns:
            A list of datasets that match the name. If no datasets with the name exist,
            an empty list is returned.

        Examples:
            >>> client = ApiWorkflowClient(token="MY_AWESOME_TOKEN")
            >>> client.create_dataset("your-dataset-name", dataset_type=DatasetType.IMAGES)
            >>> client.get_datasets_by_name(dataset_name="your-dataset-name")
            [{'created_at': 1685009504596,
             'datasource_processed_until_timestamp': 1685009513,
             'datasources': ['646f346004d77b4e1424e67e', '646f346004d77b4e1424e695'],
             'id': '646f34608a5613b57d8b73c9',
             'img_type': 'full',
             'type': 'Images',
             ...}]
            >>>
            >>> # Non-existent dataset
            >>> client.get_datasets_by_name(dataset_name="random-name")
            []
        """
        datasets: List[DatasetData] = []
        if not shared or shared is None:
            datasets.extend(
                list(
                    utils.paginate_endpoint(
                        self._datasets_api.get_datasets_query_by_name,
                        dataset_name=dataset_name,
                        exact=True,
                        shared=False,
                    )
                )
            )
        if shared or shared is None:
            datasets.extend(
                list(
                    utils.paginate_endpoint(
                        self._datasets_api.get_datasets_query_by_name,
                        dataset_name=dataset_name,
                        exact=True,
                        shared=True,
                    )
                )
            )
            datasets.extend(
                list(
                    utils.paginate_endpoint(
                        self._datasets_api.get_datasets_query_by_name,
                        dataset_name=dataset_name,
                        exact=True,
                        get_assets_of_team=True,
                    )
                )
            )

        # De-duplicate datasets because results from shared=True and
        # those from get_assets_of_team=True might overlap
        dataset_ids: Set[str] = set()
        filtered_datasets: List[DatasetData] = []
        for dataset in datasets:
            if dataset.id not in dataset_ids:
                dataset_ids.add(dataset.id)
                filtered_datasets.append(dataset)

        return filtered_datasets
Fetches datasets by name.

        There can be multiple datasets with the same name accessible to the current
        user. This can happen if either:
        * A dataset has been explicitly shared with the user
        * The user has access to team datasets
        The `shared` flag controls whether these datasets are returned.

        Args:
            dataset_name:
                Name of the target dataset.
            shared:
                * If False (default), returns only datasets owned by the user. In this
                case at most one dataset will be returned.
                * If True, returns datasets which have been shared with the user,
                including team datasets. Excludes user's own datasets. Can return
                multiple datasets.
                * If None, returns all datasets the users has access to. Can return
                multiple datasets.

        Returns:
            A list of datasets that match the name. If no datasets with the name exist,
            an empty list is returned.

        Examples:
            >>> client = ApiWorkflowClient(token="MY_AWESOME_TOKEN")
            >>> client.create_dataset("your-dataset-name", dataset_type=DatasetType.IMAGES)
            >>> client.get_datasets_by_name(dataset_name="your-dataset-name")
            [{'created_at': 1685009504596,
             'datasource_processed_until_timestamp': 1685009513,
             'datasources': ['646f346004d77b4e1424e67e', '646f346004d77b4e1424e695'],
             'id': '646f34608a5613b57d8b73c9',
             'img_type': 'full',
             'type': 'Images',
             ...}]
            >>>
            >>> # Non-existent dataset
            >>> client.get_datasets_by_name(dataset_name="random-name")
            []
        
lightly/api/api_workflow_datasets.py