def preprocess(self,
                   data: Dataset,
                   features: Union[str, List[str]],
                   label: str = 'label',
                   use_label_name: bool = True,
                   *args, **kwargs) -> List[Tuple[Any, Any]]:
        """Extracts features and labels from HuggingFace Dataset

        Args:
            data: instance of HuggingFace Dataset
            features: Dataset fields names to be extracted as features
            label: Dataset field name to be used as label.
            use_label_name: Use actual label name instead of its index (0, 1, ...). Defaults to True.

        Returns:
            List[Tuple[Any, Any]]: list of pairs of extracted features and labels
        """

        dataset = []
        for i in range(len(data)):  # for example in data
            example = data[i]
            if isinstance(features, str):
                feat = example[features]
            elif isinstance(features, list):
                try:
                    feat = tuple(example[f] for f in features)
                except Exception as e:
                    raise Exception(f"{e} for example {example} while trying to find keys {features}")
            else:
                raise RuntimeError(f"features should be str or list, but found: {features}")
            lb = example[label]
            if use_label_name and lb != -1:
                # -1 label is used if there is no label (test set)
                lb = data.info.features[label].names[lb]
            dataset += [(feat, lb)]
        return dataset
Extracts features and labels from HuggingFace Dataset

        Args:
            data: instance of HuggingFace Dataset
            features: Dataset fields names to be extracted as features
            label: Dataset field name to be used as label.
            use_label_name: Use actual label name instead of its index (0, 1, ...). Defaults to True.

        Returns:
            List[Tuple[Any, Any]]: list of pairs of extracted features and labels
        
deeppavlov/dataset_iterators/huggingface_dataset_iterator.py