class_docstr: Integration with the Hugging Face Inference API.
code: def predict(
      self,
      df: Optional[pd.DataFrame] = None,
      args: Optional[Dict] = None,
  ) -> None:
      args = self.model_storage.json_get("args")
      api_key = self._get_huggingface_api_key(args)
  
      input_column = args["input_column"]
      model_name = args["model_name"]
      endpoint = args["endpoint"] if "endpoint" in args else None
      options = args["options"] if "options" in args else None
      parameters = args["parameters"] if "parameters" in args else None
  
      if args["task"] == "text-classification":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.text_classification_in_df(
              df,
              input_column,
              options,
              model_name,
          )
          labels_map = args.get("labels_map")
  
          result_df["predictions"] = result_df["predictions"].apply(
              lambda x: labels_map.get(x, x)
          )
  
      elif args["task"] == "fill-mask":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.fill_mask_in_df(
              df, input_column, options, model_name
          )
  
      elif args["task"] == "summarization":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.summarization_in_df(
              df, input_column, parameters, options, model_name
          )
  
      elif args["task"] == "text-generation":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.text_generation_in_df(
              df, input_column, parameters, options, model_name
          )
  
      elif args["task"] == "question-answering":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.question_answering_in_df(
              df, input_column, args["context_column"], model_name
          )
  
      elif args["task"] == "sentence-similarity":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.sentence_similarity_in_df(
              df,
              input_column,
              args["input_column2"],
              options,
              model_name,
          )
  
      elif args["task"] == "zero-shot-classification":
          nlp = NLP(api_key, endpoint)
          result_df = nlp.zero_shot_classification_in_df(
              df,
              input_column,
              args["candidate_labels"],
              parameters,
              options,
              model_name,
          )
  
      elif args["task"] == "translation":
          lang_in = args["lang_input"]
          lang_out = args["lang_output"]
  
          input_origin = None
          if "task_specific_params" in args:
              task = f"translation_{lang_in}_to_{lang_out}"
              if (
                  task in args["task_specific_params"]
                  and "prefix" in args["task_specific_params"][task]
              ):
                  # inject prefix to data
                  prefix = args["task_specific_params"][task]["prefix"]
                  input_origin = df[input_column]
                  df[input_column] = prefix + input_origin
                  # don't pick up model in hugging_py_face
                  lang_in = lang_out = None
  
          nlp = NLP(api_key, endpoint)
          result_df = nlp.translation_in_df(
              df, input_column, lang_in, lang_out, options, model_name
          )
          if input_origin is not None:
              df[input_column] = input_origin
  
      elif args["task"] == "image-classification":
          cp = ComputerVision(api_key, endpoint)
          result_df = cp.image_classification_in_df(
              df, input_column, model_name
          )
  
      elif args["task"] == "object-detection":
          cp = ComputerVision(api_key, endpoint)
          result_df = cp.object_detection_in_df(
              df, input_column, model_name
          )
  
      elif args["task"] == "automatic-speech-recognition":
          ap = AudioProcessing(api_key, endpoint)
          result_df = ap.automatic_speech_recognition_in_df(
              df, input_column, model_name
          )
  
      elif args["task"] == "audio-classification":
          ap = AudioProcessing(api_key, endpoint)
          result_df = ap.audio_classification_in_df(
              df, input_column, model_name
          )
  
      result_df = result_df.rename(
          columns={"predictions": args["target"]}
      )
      return result_df
  
file_path: mindsdb/mindsdb/integrations/handlers/huggingface_api_handler/huggingface_api_handler.py
imports: import json
  import os
  from typing import Optional, Dict
  import pandas
  from huggingface_hub import HfApi
  from huggingface_hub import hf_hub_download
  from hugging_py_face import NLP, ComputerVision, AudioProcessing, get_in_df_supported_tasks
  from mindsdb.utilities.config import Config
  from mindsdb.integrations.libs.base import BaseMLEngine
  from .exceptions import UnsupportedTaskException, InsufficientParametersException
label_desc: Use image node_id 3 for calling the HuggingFaceInferenceAPIHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: result_df