code: def from_huggingface(
      ds,
      path: Optional[str] = None,
      targets: Optional[str] = None,
      data_dir: Optional[str] = None,
      data_files: Optional[
          Union[
              str,
              Sequence[str],
              Mapping[str, Union[str, Sequence[str]]],
          ]
      ] = None,
      revision=None,
      name: Optional[str] = None,
      digest: Optional[str] = None,
  ) -> HuggingFaceDataset:
      """
      Create a `mlflow.data.huggingface_dataset.HuggingFaceDataset` from a Hugging Face dataset.
  
      Args:
          ds:
              A Hugging Face dataset. Must be an instance of `datasets.Dataset`. Other types, such as
              `datasets.DatasetDict`, are not supported.
          path: The path of the Hugging Face dataset used to construct the source. This is the same
              argument as `path` in `datasets.load_dataset()` function. To be able to reload the
              dataset via MLflow, `path` must match the path of the dataset on the hub, e.g.,
              "databricks/databricks-dolly-15k". If no path is specified, a `CodeDatasetSource` is,
              used which will source information from the run context.
          targets: The name of the Hugging Face `dataset.Dataset` column containing targets (labels)
              for supervised learning.
          data_dir: The `data_dir` of the Hugging Face dataset configuration. This is used by the
              `datasets.load_dataset()` function to reload the dataset upon request via
              :py:func:`HuggingFaceDataset.source.load()
              <mlflow.data.huggingface_dataset_source.HuggingFaceDatasetSource.load>`.
          data_files: Paths to source data file(s) for the Hugging Face dataset configuration.
              This is used by the `datasets.load_dataset()` function to reload the
              dataset upon request via :py:func:`HuggingFaceDataset.source.load()
              <mlflow.data.huggingface_dataset_source.HuggingFaceDatasetSource.load>`.
          revision: Version of the dataset script to load. This is used by the
              `datasets.load_dataset()` function to reload the dataset upon request via
              :py:func:`HuggingFaceDataset.source.load()
              <mlflow.data.huggingface_dataset_source.HuggingFaceDatasetSource.load>`.
          name: The name of the dataset. E.g. "wiki_train". If unspecified, a name is automatically
              generated.
          digest: The digest (hash, fingerprint) of the dataset. If unspecified, a digest is
              automatically computed.
      """
      import datasets
  
      from mlflow.data.code_dataset_source import CodeDatasetSource
      from mlflow.tracking.context import registry
  
      if not isinstance(ds, datasets.Dataset):
          raise MlflowException(
              f"The specified Hugging Face dataset must be an instance of `datasets.Dataset`."
              f" Instead, found an instance of: {type(ds)}",
              INVALID_PARAMETER_VALUE,
          )
  
      # Set the source to a `HuggingFaceDatasetSource` if a path is specified, otherwise set it to a
      # `CodeDatasetSource`.
      if path is not None:
          source = HuggingFaceDatasetSource(
              path=path,
              config_name=ds.config_name,
              data_dir=data_dir,
              data_files=data_files,
              split=ds.split,
              revision=revision,
          )
      else:
          context_tags = registry.resolve_tags()
          source = CodeDatasetSource(tags=context_tags)
      return HuggingFaceDataset(
          ds=ds,
          targets=targets,
          source=source,
          name=name,
          digest=digest,
      )
  
imports: import json
  import logging
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Sequence, Union
  from mlflow.data.dataset import Dataset
  from mlflow.data.digest_utils import compute_pandas_digest
  from mlflow.data.huggingface_dataset_source import HuggingFaceDatasetSource
  from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin, PyFuncInputsOutputs
  from mlflow.exceptions import MlflowException
  from mlflow.models.evaluation.base import EvaluationDataset
  from mlflow.protos.databricks_pb2 import INTERNAL_ERROR, INVALID_PARAMETER_VALUE
  from mlflow.types import Schema
  from mlflow.types.utils import _infer_schema
  from mlflow.utils.annotations import experimental
label_desc: Use image node_id 1 for calling a global function with example usage: from_huggingface(ds, path, targets, data_dir, data_files, revision, name, digest) and returns: HuggingFaceDataset