code: def get_dataset(
      *,
      dataset: Union[
          None, str, pathlib.Path, Dataset, Type[Dataset]
      ] = None,
      dataset_kwargs: Optional[Mapping[str, Any]] = None,
      training: Union[
          None, str, pathlib.Path, CoreTriplesFactory
      ] = None,
      testing: Union[
          None, str, pathlib.Path, CoreTriplesFactory
      ] = None,
      validation: Union[
          None, str, pathlib.Path, CoreTriplesFactory
      ] = None,
  ) -> Dataset:
      """Get a dataset, cached based on the given kwargs.
  
      :param dataset: The name of a dataset, an instance of a dataset, or the class for a dataset.
      :param dataset_kwargs: The keyword arguments, only to be used when a class for a dataset is used for
          the ``dataset`` keyword argument.
      :param training: A triples factory for training triples or a path to a training triples file if ``dataset=None``
      :param testing: A triples factory for testing triples or a path to a testing triples file  if ``dataset=None``
      :param validation: A triples factory for validation triples or a path to a validation triples file
          if ``dataset=None``
      :returns: An instantiated dataset
  
      :raises ValueError: for incorrect usage of the input of the function
      :raises TypeError: If a type is given for ``dataset`` but it's not a subclass of
          :class:`pykeen.datasets.Dataset`
      """
      from . import dataset_resolver, has_dataset
  
      if dataset is None and (training is None or testing is None):
          raise ValueError(
              "Must specify either dataset or both training/testing triples factories"
          )
  
      if dataset is not None and (
          training is not None or testing is not None
      ):
          raise ValueError(
              "Can not specify both dataset and training/testing triples factories."
          )
  
      if isinstance(dataset, Dataset):
          if dataset_kwargs:
              logger.warning(
                  "dataset_kwargs not used since a pre-instantiated dataset was given"
              )
          return dataset
  
      if isinstance(dataset, pathlib.Path):
          return Dataset.from_path(dataset)
  
      # convert class to string to use caching
      if isinstance(dataset, type) and issubclass(dataset, Dataset):
          dataset = dataset_resolver.normalize_cls(cls=dataset)
  
      if isinstance(dataset, str):
          if has_dataset(dataset):
              return _cached_get_dataset(dataset, dataset_kwargs)
          else:
              # Assume it's a file path
              return Dataset.from_path(dataset)
  
      if dataset is not None:
          raise TypeError(f"Dataset is invalid type: {type(dataset)}")
  
      if isinstance(training, (str, pathlib.Path)) and isinstance(
          testing, (str, pathlib.Path)
      ):
          if validation is None or isinstance(
              validation, (str, pathlib.Path)
          ):
              return PathDataset(
                  training_path=training,
                  testing_path=testing,
                  validation_path=validation,
                  **(dataset_kwargs or {}),
              )
          elif validation is not None:
              raise TypeError(
                  f"Validation is invalid type: {type(validation)}"
              )
  
      if isinstance(training, CoreTriplesFactory) and isinstance(
          testing, CoreTriplesFactory
      ):
          if validation is not None and not isinstance(
              validation, CoreTriplesFactory
          ):
              raise TypeError(
                  f"Validation is invalid type: {type(validation)}"
              )
          if dataset_kwargs:
              logger.warning(
                  "dataset_kwargs are disregarded when passing pre-instantiated triples factories"
              )
          return EagerDataset(
              training=training,
              testing=testing,
              validation=validation,
          )
  
      raise TypeError(
          f"""Training and testing must both be given as strings or Triples Factories.
          - Training: {type(training)}: {training}
          - Testing: {type(testing)}: {testing}
          """,
      )
  
file_path: pykeen/src/pykeen/datasets/utils.py
imports: import base64
  import hashlib
  import logging
  import pathlib
  import re
  from typing import Any, Collection, Iterable, Mapping, Optional, Pattern, Tuple, Type, Union
  import click
  from tqdm import tqdm
  from .base import Dataset, EagerDataset, PathDataset
  from ..constants import PYKEEN_DATASETS
  from ..triples import CoreTriplesFactory
label_desc: Use image node_id 3 for calling a global function with example usage: get_dataset() and returns: dataset, Dataset, EagerDataset, _cached_get_dataset, Dataset, PathDataset