class_docstr: CLIP is a recent model by OpenAI.
  
  Attributes:
      model_path: ViT-B/32, RN50, RN101, RN50x4
      init_model: initialise model from model_path
      init_tokenizer: initializes tokenizer
      name: string identifier for the model. Lowercase letters and numbers.
          No spaces/special characters except dashes.
      description: String description of the model.
      tasks: List of supported task strings
      details: Dictionary of additional details about the model
      device: Device for model. Defaults to "cuda" if available.
class_docstr_tok: ["CLIP","is","a","recent","model","by","OpenAI",".","Attributes",":","model_path",":","ViT-B\/32",",","RN50",",","RN101",",","RN50x4","init_model",":","initialise","model","from","model_path","init_tokenizer",":","initializes","tokenizer","name",":","string","identifier","for","the","model",".","Lowercase","letters","and","numbers",".","No","spaces\/special","characters","except","dashes",".","description",":","String","description","of","the","model",".","tasks",":","List","of","supported","task","strings","details",":","Dictionary","of","additional","details","about","the","model","device",":","Device","for","model",".","Defaults","to","``","cuda","''","if","available","."]
docstr: Do inference with the model.
  
  Args:
      task_input: input dictionary according to task
      task: one of supported tasks
      return_tensor: return a tensor instead of list for vectorisation output
docstr_tok: ["Do","inference","with","the","model",".","Args",":","task_input",":","input","dictionary","according","to","task","task",":","one","of","supported","tasks","return_tensor",":","return","a","tensor","instead","of","list","for","vectorisation","output"]
code: def __call__(
      self, task_input, task="image-classification", return_tensor=False
  ):
      """
      Do inference with the model.
  
      Args:
          task_input: input dictionary according to task
          task: one of supported tasks
          return_tensor: return a tensor instead of list for vectorisation output
      """
      output = None
      is_list = False
  
      if task == "image-classification":
          image = task_input.get("image")
          labels = task_input.get("labels")
          top_k = task_input.get("top_k", 10000)
  
          image = base64_to_img(image)
  
          if labels is None:
              raise ValueError("labels must be provided")
  
          is_list = type(image) == list
          if not is_list:
              image = [image]
              labels = [labels]
  
          image = [
              self.process_image(img)
              .unsqueeze(0)
              .to(self._model_device)
              for img in image
          ]
          text = [
              self.tokenizer(l).to(self._model_device) for l in labels
          ]
  
          output = self.image_classification(
              image=image, text=text, labels=labels, top_k=top_k
          )
  
      elif task == "image-vectorisation":
          image = task_input.get("image")
  
          image = base64_to_img(image)
  
          is_list = type(image) == list
          if not is_list:
              image = [image]
  
          image = [self.process_image(img) for img in image]
          image = torch.stack(image).to(self._model_device)
  
          img_vecs = self.image_vectorisation(image=image)
  
          if not return_tensor:
              img_vecs = img_vecs.tolist()
  
          output = img_vecs
  
      elif task == "text-vectorisation":
          text = task_input.get("text")
  
          is_list = type(text) == list
          if not is_list:
              text = [text]
  
          text = self.tokenizer(text).to(self._model_device)
  
          text_vecs = self.text_vectorisation(text=text)
  
          if not return_tensor:
              text_vecs = text_vecs.tolist()
  
          output = text_vecs
  
      elif task == "image-text-vectorisation":
          image = task_input.get("image")
          text = task_input.get("text")
  
          image = base64_to_img(image)
  
          is_list = type(image) == list
          if not is_list:
              image = [image]
              text = [text]
  
          text = self.tokenizer(text).to(self._model_device)
          image = [self.process_image(img) for img in image]
          image = torch.stack(image).to(self._model_device)
  
          img_text_vecs = self.image_text_vectorisation(image, text)
  
          if not return_tensor:
              img_text_vecs = img_text_vecs.tolist()
  
          output = img_text_vecs
  
      if not is_list:
          output = output[0]
  
      return output
  
imports: import torch
  import torch.nn.functional
  from torch.utils.data.sampler import Sampler
  import pytorch_lightning
  import numpy
  from PIL import Image
  from typing import Union, List, Dict
  from functools import partial
  from .None import clip, simple_tokenizer
  from backprop.models import BaseModel
  from backprop.utils import ImageTextGroupDataset, base64_to_img
  from backprop.utils.losses import TripletLoss
  from io import BytesIO
  import base64
  import random
  from torch.utils.data.dataloader import DataLoader
  import os
label_desc: Use image node_id 3 for calling the CLIP obj's underlying member method code with example usage: obj.__call__(task_input, task, return_tensor) and returns: output