class_docstr: Dataset iterator for HuggingFace Datasets.
docstr: 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
docstr_tok: ["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"]
code: 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
  
imports: from typing import List, Tuple, Any, Union
  from datasets import Dataset
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.data_learning_iterator import DataLearningIterator
label_desc: Use image node_id 1 for calling the HuggingFaceDatasetIterator obj's underlying member method code with example usage: obj.preprocess(data, features, label, use_label_name) and returns: dataset