class_docstr: Task for classification.
  
  Attributes:
      model:
          1. Model name
          2. Model name on Backprop's text-classification endpoint
          3. Model object that implements the text-classification task
      local (optional): Run locally. Defaults to False
      api_key (optional): Backprop API key for non-local inference
      device (optional): Device to run inference on. Defaults to "cuda" if available.
class_docstr_tok: ["Task","for","classification",".","Attributes",":","model",":","1",".","Model","name","2",".","Model","name","on","Backprop","'s","text-classification","endpoint","3",".","Model","object","that","implements","the","text-classification","task","local","(","optional",")",":","Run","locally",".","Defaults","to","False","api_key","(","optional",")",":","Backprop","API","key","for","non-local","inference","device","(","optional",")",":","Device","to","run","inference","on",".","Defaults","to","``","cuda","''","if","available","."]
docstr: Classify input text based on previous training (user-tuned models) or according to given list of labels (zero-shot)
  
  Args:
      text: string or list of strings to be classified
      labels: list of labels for zero-shot classification (on our out-of-the-box models).
              If using a user-trained model (e.g. XLNet), this is not used.
      top_k: return probabilities only for top_k predictions. Use 0 to get all.
  
  Returns:
      dict where each key is a label and value is probability between 0 and 1, or list of dicts.
docstr_tok: ["Classify","input","text","based","on","previous","training","(","user-tuned","models",")","or","according","to","given","list","of","labels","(","zero-shot",")","Args",":","text",":","string","or","list","of","strings","to","be","classified","labels",":","list","of","labels","for","zero-shot","classification","(","on","our","out-of-the-box","models",")",".","If","using","a","user-trained","model","(","e.g",".","XLNet",")",",","this","is","not","used",".","top_k",":","return","probabilities","only","for","top_k","predictions",".","Use","0","to","get","all",".","Returns",":","dict","where","each","key","is","a","label","and","value","is","probability","between","0","and","1",",","or","list","of","dicts","."]
code: def __call__(
      self,
      text: Union[str, List[str]],
      labels: Optional[Union[List[str], List[List[str]]]] = None,
      top_k: int = 0,
  ):
      """Classify input text based on previous training (user-tuned models) or according to given list of labels (zero-shot)
  
      Args:
          text: string or list of strings to be classified
          labels: list of labels for zero-shot classification (on our out-of-the-box models).
                  If using a user-trained model (e.g. XLNet), this is not used.
          top_k: return probabilities only for top_k predictions. Use 0 to get all.
  
      Returns:
          dict where each key is a label and value is probability between 0 and 1, or list of dicts.
      """
      task_input = {
          "text": text,
          "labels": labels,
          "top_k": top_k,
      }
  
      if top_k == 0:
          task_input.pop("top_k")
  
      if self.local:
          return self.model(task_input, task=TASK)
      else:
          task_input["model"] = self.model
  
          res = requests.post(
              "https://api.backprop.co/text-classification",
              json=task_input,
              headers={"x-api-key": self.api_key},
          ).json()
  
          if res.get("message"):
              raise Exception(
                  f"Failed to make API request: {res['message']}"
              )
  
          return res["probabilities"]
  
file_path: backprop/backprop/tasks/text_classification.py
imports: from typing import List, Tuple, Union, Optional
  from backprop.models import BaseModel, AutoModel
  from .base import Task
  import torch
  from transformers.optimization import AdamW
  from backprop.utils.datasets import SingleLabelTextClassificationDataset
  import requests
label_desc: Use image node_id 3 for calling the TextClassification obj's underlying member method code with example usage: obj.__call__(text, labels, top_k) and returns: self, res