class_docstr: Base class for Image-Text multi-modal learning
  
  Args:
      opts: command-line arguments
class_docstr_tok: ["Base","class","for","Image-Text","multi-modal","learning","Args",":","opts",":","command-line","arguments"]
docstr: Helper function to transform the text tensor. If the text tensor is smaller
  than the context length, it pads it and replaces the last token with EOT token.
  
  Args:
      text_tensor: Text tensor with N tokens. Shape is (N,).
  
  Returns:
      A Tuple of text tensor (whole length is equal to context length) and length of the tensor.
docstr_tok: ["Helper","function","to","transform","the","text","tensor",".","If","the","text","tensor","is","smaller","than","the","context","length",",","it","pads","it","and","replaces","the","last","token","with","EOT","token",".","Args",":","text_tensor",":","Text","tensor","with","N","tokens",".","Shape","is","(","N",",",")",".","Returns",":","A","Tuple","of","text","tensor","(","whole","length","is","equal","to","context","length",")","and","length","of","the","tensor","."]
code: def _transform_text(self, text_tensor: Tensor) -> Tuple[Tensor, int]:
      """Helper function to transform the text tensor. If the text tensor is smaller
      than the context length, it pads it and replaces the last token with EOT token.
  
      Args:
          text_tensor: Text tensor with N tokens. Shape is (N,).
  
      Returns:
          A Tuple of text tensor (whole length is equal to context length) and length of the tensor.
      """
      captions_tensor = torch.zeros(
          size=(self.context_length,), dtype=torch.long
      )
  
      text_len = text_tensor.shape[0]
      if text_len > self.context_length:
          text_tensor = text_tensor[: self.context_length]
          text_tensor[-1] = self.text_tokenizer.get_eot_token()
          text_len = self.context_length
      captions_tensor[:text_len] = text_tensor[:text_len]
      return captions_tensor, text_len
  
imports: import argparse
  import os
  from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
  import torch
  from PIL import Image
  from torch import Tensor
  from data.collate_fns import COLLATE_FN_REGISTRY
  from data.datasets.dataset_base import BaseImageDataset
  from data.datasets.multi_modal_img_text.zero_shot import BaseZeroShotDataset, build_zero_shot_dataset
  from data.datasets.utils.text import caption_preprocessing
  from data.text_tokenizer import build_tokenizer
  from data.transforms import image_pil
  from data.transforms.common import Compose
  from utils import logger
  from utils.ddp_utils import is_master, is_start_rank_node
label_desc: Use image node_id 6 for calling the BaseMultiModalImgText obj's underlying member method code with example usage: obj._transform_text(text_tensor) and returns: captions_tensor,  text_len