docstr: Sets the dataset ID in the API client given the name of the desired dataset.
  
  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 also checked. If multiple
  datasets with the given name are found, the API client uses the ID of the first
  dataset and prints a warning message.
  
  Args:
      dataset_name:
          The name of the target dataset.
      shared:
          * If False (default), checks only datasets owned by the user.
          * If True, returns datasets which have been shared with the user,
          including team datasets. Excludes user's own datasets. There can be
          multiple candidate datasets.
          * If None, returns all datasets the users has access to. There can be
          multiple candidate datasets.
  
  Raises:
      ValueError:
          If no dataset with the given name exists.
  
  Examples:
      >>> # A new session. Dataset "old-dataset" was created before.
      >>> client = ApiWorkflowClient(token="MY_AWESOME_TOKEN")
      >>> client.set_dataset_id_by_name("old-dataset")
docstr_tok: ["Sets","the","dataset","ID","in","the","API","client","given","the","name","of","the","desired","dataset",".","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","also","checked",".","If","multiple","datasets","with","the","given","name","are","found",",","the","API","client","uses","the","ID","of","the","first","dataset","and","prints","a","warning","message",".","Args",":","dataset_name",":","The","name","of","the","target","dataset",".","shared",":","*","If","False","(","default",")",",","checks","only","datasets","owned","by","the","user",".","*","If","True",",","returns","datasets","which","have","been","shared","with","the","user",",","including","team","datasets",".","Excludes","user","'s","own","datasets",".","There","can","be","multiple","candidate","datasets",".","*","If","None",",","returns","all","datasets","the","users","has","access","to",".","There","can","be","multiple","candidate","datasets",".","Raises",":","ValueError",":","If","no","dataset","with","the","given","name","exists",".","Examples",":",">",">",">","#","A","new","session",".","Dataset","``","old-dataset","''","was","created","before",".",">",">",">","client","=","ApiWorkflowClient","(","token=","''","MY_AWESOME_TOKEN","''",")",">",">",">","client.set_dataset_id_by_name","(","``","old-dataset","''",")"]
code: def set_dataset_id_by_name(
      self, dataset_name: str, shared: Optional[bool] = False
  ) -> None:
      """Sets the dataset ID in the API client given the name of the desired dataset.
  
      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 also checked. If multiple
      datasets with the given name are found, the API client uses the ID of the first
      dataset and prints a warning message.
  
      Args:
          dataset_name:
              The name of the target dataset.
          shared:
              * If False (default), checks only datasets owned by the user.
              * If True, returns datasets which have been shared with the user,
              including team datasets. Excludes user's own datasets. There can be
              multiple candidate datasets.
              * If None, returns all datasets the users has access to. There can be
              multiple candidate datasets.
  
      Raises:
          ValueError:
              If no dataset with the given name exists.
  
      Examples:
          >>> # A new session. Dataset "old-dataset" was created before.
          >>> client = ApiWorkflowClient(token="MY_AWESOME_TOKEN")
          >>> client.set_dataset_id_by_name("old-dataset")
      """
      datasets = self.get_datasets_by_name(
          dataset_name=dataset_name, shared=shared
      )
      if not datasets:
          raise ValueError(
              f"A dataset with the name '{dataset_name}' does not exist on the "
              f"Lightly Platform. Please create it first."
          )
      self._dataset_id = datasets[0].id
      if len(datasets) > 1:
          msg = (
              f"Found {len(datasets)} datasets with the name '{dataset_name}'. Their "
              f"ids are {[dataset.id for dataset in datasets]}. "
              f"The dataset_id of the client was set to '{self._dataset_id}'. "
          )
          if shared or shared is None:
              msg += (
                  f"We noticed that you set shared={shared} which also retrieves "
                  f"datasets shared with you. Set shared=False to only consider "
                  "datasets you own."
              )
          warnings.warn(msg)
  
imports: import warnings
  from itertools import chain
  from typing import Iterator, List, Optional, Set
  from lightly.api import utils
  from lightly.openapi_generated.swagger_client.models import CreateEntityResponse, DatasetCreateRequest, DatasetData, DatasetType
  from lightly.openapi_generated.swagger_client.rest import ApiException
label_desc: Use image node_id 10 for calling the _DatasetsMixin obj's underlying member method code with example usage: obj.set_dataset_id_by_name(dataset_name, shared) without return types