class_docstr: CLIP model
  Args:
      embed_dim (int): embedding dimension
      image_resolution (int): image resolution
      vision_layers (Union[Tuple[int, int, int, int], int]): configs for vision transformer layers
      vision_width (int): width of vision transformer
      vision_patch_size (int): patch size of vision transformer
      multilingual_model (str): config for multilingual model
      context_length (int): length of context
      vocab_size (int): vocabulary size
      transformer_width (int): width of transformer
      transformer_heads (int): heads number of transformer
      transformer_layers (int): layer number of transformer
      clip4clip (bool): is clip4clip or not
      vis (bool): visualization
      is_bridge_former (bool): is bridge model or not
      is_bridge_former_video (bool): text transformer or visual transformer for a single frame
code: def encode_text(
      self,
      text,
      clip4clip=False,
      return_hidden=False,
      multilingual=False,
      device=None,
  ):
      if device is None:
          device = "cuda" if torch.cuda.is_available() else "cpu"
      if multilingual:
          assert (
              self.multilingual_model is not None
          ), "Multilingual is not supported yet."
          assert isinstance(
              text[0], str
          ), "Multilingual is only supported for inputs in text or list of texts."
          try:
              from multilingual_clip import (
                  pt_multilingual_clip,
              )  # pylint: disable=C0415
          except ModuleNotFoundError:
              os.system("pip install multilingual-clip")
              from multilingual_clip import (
                  pt_multilingual_clip,
              )  # pylint: disable=C0415
          try:
              import transformers  # pylint: disable=C0415
          except ModuleNotFoundError:
              os.system("pip install transformers")
              import transformers  # pylint: disable=C0415
  
          tokenizer = transformers.AutoTokenizer.from_pretrained(
              self.multilingual_model
          )
          encoder = (
              pt_multilingual_clip.MultilingualCLIP.from_pretrained(
                  self.multilingual_model
              )
          )
          x = encoder(text, tokenizer)
          return x
      else:
          if isinstance(text[0], str):
              text = tokenize(text).to(device)
          else:
              text = text.to(device)
          if clip4clip:
              x = self.token_embedding(text).type(
                  self.dtype
              )  # [batch_size, n_ctx, d_model]
  
              pos_emd = self.positional_embedding[: x.size(1), :].type(
                  self.dtype
              )
              x = x + pos_emd
              x = x.permute(1, 0, 2)  # NLD -> LND
              x = self.transformer(x)
              x = x.permute(1, 0, 2)  # LND -> NLD
  
              hidden = (
                  self.ln_final(x).type(self.dtype)
                  @ self.text_projection
              )
  
              # x.shape = [batch_size, n_ctx, transformer.width]
              # take features from the eot embedding (eot_token is the highest number in each sequence)
              x = hidden[
                  torch.arange(hidden.shape[0]), text.argmax(dim=-1)
              ]
  
              if return_hidden:
                  return x, hidden
          else:
              x = self.token_embedding(text).type(
                  self.dtype
              )  # [batch_size, n_ctx, d_model]
  
              x = x + self.positional_embedding.type(self.dtype)
              x = x.permute(1, 0, 2)  # NLD -> LND
              x = self.transformer(x)
              x = x.permute(1, 0, 2)  # LND -> NLD
              x = self.ln_final(x).type(self.dtype)
  
              x = (
                  x[torch.arange(x.shape[0]), text.argmax(dim=-1)]
                  @ self.text_projection
              )
  
          return x
  
imports: import os
  import warnings
  from collections import OrderedDict
  from typing import Tuple, Union, Callable
  import numpy
  from PIL import Image
  import torch
  from torch import nn
  from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
  from towhee.models.utils.download import download_from_url
  from towhee.models.clip.clip_utils import get_configs, convert_weights, patch_device, patch_float, tokenize
  from towhee.models.clip.auxilary import multi_head_attention_forward, MultiheadAttention
label_desc: Use image node_id 8 for calling the CLIP obj's underlying member method code with example usage: obj.encode_text(text, clip4clip, return_hidden, multilingual, device) and returns: x, x, x,  hidden