class_docstr: Task for text vectorisation.
  
  Attributes:
      model:
          1. Model name
          2. Model name on Backprop's text-vectorisation endpoint
          3. Model object that implements the text-vectorisation 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","text","vectorisation",".","Attributes",":","model",":","1",".","Model","name","2",".","Model","name","on","Backprop","'s","text-vectorisation","endpoint","3",".","Model","object","that","implements","the","text-vectorisation","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: Vectorise input text.
  
  Args:
      text: string or list of strings to vectorise. Can be both PIL Image objects or paths to images.
  
  Returns:
      Vector or list of vectors
docstr_tok: ["Vectorise","input","text",".","Args",":","text",":","string","or","list","of","strings","to","vectorise",".","Can","be","both","PIL","Image","objects","or","paths","to","images",".","Returns",":","Vector","or","list","of","vectors"]
code: def __call__(self, text: Union[str, List[str]], return_tensor=False):
      """Vectorise input text.
  
      Args:
          text: string or list of strings to vectorise. Can be both PIL Image objects or paths to images.
  
      Returns:
          Vector or list of vectors
      """
      vector = None
  
      if self.local:
          task_input = {"text": text}
          vector = self.model(task_input, task=TASK)
      else:
          body = {"text": text, "model": self.model}
  
          res = requests.post(
              "https://api.backprop.co/text-vectorisation",
              json=body,
              headers={"x-api-key": self.api_key},
          ).json()
  
          if res.get("message"):
              raise Exception(
                  f"Failed to make API request: {res['message']}"
              )
  
          vector = res["vector"]
  
      if return_tensor and not isinstance(vector, torch.Tensor):
          vector = torch.tensor(vector)
  
      return vector
  
imports: from typing import List, Tuple, Union
  from .base import Task
  from backprop.models import AutoModel, BaseModel
  import requests
  import torch.nn.functional
  import torch
  from torch.utils.data.dataloader import DataLoader
  import os
  import random
  from functools import partial
  from backprop.utils.datasets import TextGroupDataset, TextPairDataset
  from backprop.utils.samplers import SameGroupSampler
  from backprop.utils.losses.triplet_loss import TripletLoss
label_desc: Use image node_id 3 for calling the TextVectorisation obj's underlying member method code with example usage: obj.__call__(text, return_tensor) and returns: vector