def _huggingface_format(dataset: Union["FeedbackDataset", "RemoteFeedbackDataset"]) -> "Dataset":
        """Formats either a `FeedbackDataset` or a `RemoteFeedbackDataset` as a `datasets.Dataset` object.

        Args:
            dataset: The `FeedbackDataset` or `RemoteFeedbackDataset` to format as `datasets.Dataset`.

        Returns:
            The records from the dataset formatted as a `datasets.Dataset` object, including the fields,
            questions, and metadata_properties formatted as `datasets.Features`.

        Examples:
            >>> from argilla_v1.client.feedback.integrations.huggingface import HuggingFaceDatasetMixin
            >>> dataset = FeedbackDataset(...) or RemoteFeedbackDataset(...)
            >>> huggingface_dataset = HuggingFaceDatasetMixin._huggingface_format(dataset)
        """
        from datasets import Dataset, Features, Sequence, Value

        hf_dataset, hf_features = {}, {}

        for field in dataset.fields:
            if field.type not in FIELD_TYPE_TO_PYTHON_TYPE.keys():
                raise ValueError(
                    f"Field {field.name} has an unsupported type: {field.type}, for the moment"
                    f" only the following types are supported: {list(FIELD_TYPE_TO_PYTHON_TYPE.keys())}"
                )
            hf_features[field.name] = Value(dtype="string", id="field")
            if field.name not in hf_dataset:
                hf_dataset[field.name] = []

        for question in dataset.questions:
            if question.type in [QuestionTypes.text, QuestionTypes.label_selection]:
                value = Value(dtype="string", id="question")
                suggestion_value = copy(value)
            elif question.type == QuestionTypes.rating:
                value = Value(dtype="int32", id="question")
                suggestion_value = copy(value)
            elif question.type == QuestionTypes.ranking:
                value = Sequence({"rank": Value(dtype="uint8"), "value": Value(dtype="string")}, id="question")
                suggestion_value = copy(value)
            elif question.type in QuestionTypes.multi_label_selection:
                value = Sequence(Value(dtype="string"), id="question")
                suggestion_value = copy(value)
            elif question.type in QuestionTypes.span:
                value = Sequence(
                    {
                        "start": Value(dtype="int32"),
                        "end": Value(dtype="int32"),
                        "label": Value(dtype="string"),
                        "text": Value(dtype="string"),
                    },
                    id="question",
                )
                suggestion_value = Sequence(
                    {
                        "start": Value(dtype="int32"),
                        "end": Value(dtype="int32"),
                        "label": Value(dtype="string"),
                        "text": Value(dtype="string"),
                        "score": Value(dtype="float32"),
                    }
                )
            else:
                raise ValueError(
                    f"Question {question.name} is of type `{question.type}`,"
                    " for the moment only the following question types are supported:"
                    f" `{'`, `'.join(QuestionTypes.values())}`."
                )

            hf_features[question.name] = [
                {
                    "user_id": Value(dtype="string", id="question"),
                    "value": value,
                    "status": Value(dtype="string", id="question"),
                }
            ]
            if question.name not in hf_dataset:
                hf_dataset[question.name] = []

            suggestion_value.id = "suggestion"
            hf_features[f"{question.name}-suggestion"] = suggestion_value
            if f"{question.name}-suggestion" not in hf_dataset:
                hf_dataset[f"{question.name}-suggestion"] = []

            score_type = Value(dtype="float32", id="suggestion-metadata")
            if question.type in [QuestionTypes.span, QuestionTypes.multi_label_selection, QuestionTypes.ranking]:
                score_type = Sequence(score_type)
            hf_features[f"{question.name}-suggestion-metadata"] = {
                "type": Value(dtype="string", id="suggestion-metadata"),
                "score": score_type,
                "agent": Value(dtype="string", id="suggestion-metadata"),
            }
            if f"{question.name}-suggestion-metadata" not in hf_dataset:
                hf_dataset[f"{question.name}-suggestion-metadata"] = []

        hf_features["external_id"] = Value(dtype="string", id="external_id")
        hf_dataset["external_id"] = []

        hf_features["metadata"] = Value(dtype="string", id="metadata")
        hf_dataset["metadata"] = []

        vectors_settings = dataset.vectors_settings
        if vectors_settings:
            hf_features["vectors"] = {}
            for vector_settings in vectors_settings:
                hf_features["vectors"].update({vector_settings.name: Sequence(Value(dtype="float32"), id="vectors")})
            hf_dataset["vectors"] = []

        for record in dataset.records:
            for field in dataset.fields:
                hf_dataset[field.name].append(record.fields.get(field.name, None))
            for question in dataset.questions:
                if not record.responses:
                    hf_dataset[question.name].append([])
                else:
                    responses = []
                    for response in record.responses:
                        if question.name not in response.values:
                            continue
                        formatted_response = {
                            "user_id": response.user_id,
                            "value": None,
                            "status": response.status.value if hasattr(response.status, "value") else response.status,
                        }
                        if question.type == QuestionTypes.ranking:
                            value = [r.dict() for r in response.values[question.name].value]
                        elif question.type == QuestionTypes.span:
                            value = [
                                {
                                    "start": span.start,
                                    "end": span.end,
                                    "label": span.label,
                                    "text": record.fields[question.field][span.start : span.end],
                                }
                                for span in response.values[question.name].value
                            ]
                        else:
                            value = response.values[question.name].value
                        formatted_response["value"] = value
                        responses.append(formatted_response)
                    hf_dataset[question.name].append(responses)

                suggestion_value, suggestion_metadata = None, {"type": None, "score": None, "agent": None}
                if record.suggestions:
                    for suggestion in record.suggestions:
                        if question.name == suggestion.question_name:
                            if question.type == QuestionTypes.span:
                                suggestion_value = [
                                    {
                                        "start": span.start,
                                        "end": span.end,
                                        "label": span.label,
                                        "score": span.score,
                                        "text": record.fields[question.field][span.start : span.end],
                                    }
                                    for span in suggestion.value
                                ]
                            else:
                                suggestion_value = suggestion.dict(include={"value"})["value"]

                            suggestion_metadata = {
                                "type": suggestion.type,
                                "score": suggestion.score,
                                "agent": suggestion.agent,
                            }
                            break
                hf_dataset[f"{question.name}-suggestion"].append(suggestion_value)
                hf_dataset[f"{question.name}-suggestion-metadata"].append(suggestion_metadata)

            hf_dataset["metadata"].append(json.dumps(record.metadata) if record.metadata else {})
            hf_dataset["external_id"].append(record.external_id or None)

            if vectors_settings:
                vectors = {}
                for vector_settings in vectors_settings:
                    vectors.update({vector_settings.name: record.vectors.get(vector_settings.name, None)})
                hf_dataset["vectors"].append(vectors)

        return Dataset.from_dict(hf_dataset, features=Features(hf_features))
Formats either a `FeedbackDataset` or a `RemoteFeedbackDataset` as a `datasets.Dataset` object.

        Args:
            dataset: The `FeedbackDataset` or `RemoteFeedbackDataset` to format as `datasets.Dataset`.

        Returns:
            The records from the dataset formatted as a `datasets.Dataset` object, including the fields,
            questions, and metadata_properties formatted as `datasets.Features`.

        Examples:
            >>> from argilla_v1.client.feedback.integrations.huggingface import HuggingFaceDatasetMixin
            >>> dataset = FeedbackDataset(...) or RemoteFeedbackDataset(...)
            >>> huggingface_dataset = HuggingFaceDatasetMixin._huggingface_format(dataset)
        
argilla-v1/src/argilla_v1/client/feedback/integrations/huggingface/dataset.py