code: def encode_text(
      self,
      indices: Tensor,
      *,
      apply_pooling: bool = True,
      determinate: bool = True,
      clip_skip: int = 0,
  ) -> Tensor:
      fmt = (
          "`{}` is not initialized, "
          "please set `use_text=True` when initializing `CLIP`"
      )
      if self.token_embedding is None:
          raise ValueError(fmt.format("token_embedding"))
      if self.text_transformer is None:
          raise ValueError(fmt.format("text_transformer"))
      if self.text_latent_dropout is None:
          raise ValueError(fmt.format("text_latent_dropout"))
      if self.text_projection is None:
          raise ValueError(fmt.format("text_projection"))
      net = self.token_embedding(indices)
      if self.token_type_embedding is not None:
          token_type = torch.zeros_like(indices)
          net = net + self.token_type_embedding(token_type)
      kw = dict(clip_skip=clip_skip, determinate=determinate)
      net = self.text_transformer(0, {INPUT_KEY: net}, **kw)[LATENT_KEY]
      if not apply_pooling:
          return net
      # 'pool' the latent net if pooler is not provided
      if self.text_head_pooler is None:
          batch_size = net.shape[0]
          if self.training or batch_size > 1:
              net = net[
                  torch.arange(batch_size), indices.argmax(dim=-1)
              ]
          else:
              # ONNX compatibility
              net = net[:, torch.nonzero(indices)[:, 1][-1]]
      net = self.text_latent_dropout(net)
      net = self.text_projection(net)
      return l2_normalize(net)
  
imports: import torch
  from torch import nn
  from torch import Tensor
  from typing import Optional
  from cftool.cv import to_rgb
  from cftool.array import l2_normalize
  from torchvision.transforms import Resize
  from torchvision.transforms import Compose
  from torchvision.transforms import ToTensor
  from torchvision.transforms import Normalize
  from torchvision.transforms import CenterCrop
  from torchvision.transforms import InterpolationMode
  from .schema import IPerceptor
  from ...constants import INPUT_KEY
  from ...constants import LATENT_KEY
  from ...modules.blocks import HijackLinear
  from ..cv.encoder.transformer import ViTEncoder
  from ..nlp.encoder.transformer import TeTEncoder
label_desc: Use image node_id 6 for calling the CLIP obj's underlying member method code with example usage: obj.encode_text(indices) and returns: l2_normalize, net