class_docstr: Task for image classification.
  
  Attributes:
      model:
          1. Model name
          2. Model name on Backprop's image-classification endpoint
          3. Model object that implements the image-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","image","classification",".","Attributes",":","model",":","1",".","Model","name","2",".","Model","name","on","Backprop","'s","image-classification","endpoint","3",".","Model","object","that","implements","the","image-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 image according to given labels.
  
  Args:
      image: image or list of images to vectorise. Can be both PIL Image objects or paths to images.
      labels: list of strings or list of labels (for zero shot classification)
      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","image","according","to","given","labels",".","Args",":","image",":","image","or","list","of","images","to","vectorise",".","Can","be","both","PIL","Image","objects","or","paths","to","images",".","labels",":","list","of","strings","or","list","of","labels","(","for","zero","shot","classification",")","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,
      image: Union[str, List[str]],
      labels: Union[List[str], List[List[str]]] = None,
      top_k: int = 0,
  ):
      """Classify image according to given labels.
  
      Args:
          image: image or list of images to vectorise. Can be both PIL Image objects or paths to images.
          labels: list of strings or list of labels (for zero shot classification)
          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
      """
  
      image = path_to_img(image)
  
      task_input = {
          "image": image,
          "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["image"] = img_to_base64(task_input["image"])
          task_input["model"] = self.model
  
          res = requests.post(
              "https://api.backprop.co/image-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"]
  
imports: from typing import List, Tuple, Union
  from ..models import BaseModel
  from backprop.models import AutoModel
  from backprop.utils.datasets import SingleLabelImageClassificationDataset, MultiLabelImageClassificationDataset
  from .base import Task
  from PIL import Image
  from torch import nn
  import torch
  import numpy
  import base64
  import requests
  from io import BytesIO
  from backprop.utils.helpers import img_to_base64, path_to_img
label_desc: Use image node_id 3 for calling the ImageClassification obj's underlying member method code with example usage: obj.__call__(image, labels, top_k) and returns: self, res