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"]
code: def __init__(
      self,
      opts,
      *args,
      **kwargs,
  ) -> None:
      super().__init__(
          opts=opts,
          *args,
          **kwargs,
      )
  
      self.is_master_node = is_master(opts)
      self.is_start_rank_node = is_start_rank_node(opts)
  
      self.text_tokenizer = build_tokenizer(opts=opts, *args, **kwargs)
      self.context_length = getattr(
          opts, "dataset.multi_modal_img_text.context_length"
      )
  
      # for sharing padding index across the entire cvnets framework, we will
      # use a special variable "dataset.padding_index".
      setattr(opts, "dataset.padding_index", None)
      self.padding_index = getattr(opts, "dataset.padding_index")
  
      vocab_size = self.text_tokenizer.get_vocab_size()
      if vocab_size is None or vocab_size == -1:
          logger.error(
              "Vocab size can't be None or -1 in {}. Got: {}".format(
                  self.__class__.__name__, vocab_size
              )
          )
      self.vocab_size = vocab_size
      setattr(opts, "dataset.text_vocab_size", vocab_size)
      setattr(opts, "dataset.text_context_length", self.context_length)
  
      setattr(
          opts,
          "dataset.collate_fn_name_train",
          "multi_modal_img_text_collate_fn",
      )
      setattr(
          opts,
          "dataset.collate_fn_name_val",
          "multi_modal_img_text_collate_fn",
      )
      setattr(
          opts,
          "dataset.collate_fn_name_test",
          "multi_modal_img_text_collate_fn",
      )
  
      self.zero_shot_dataset = self.get_zero_shot_dataset(
          *args, **kwargs
      )
      self.cached_zero_shot_captions = None
  
      self.cache_loc = os.path.join(self.root, ".img_text_tar_cache")
      if self.is_training:
          # Folder where we will download data
          # TODO: Training data can't fit on a single node, so we save/cache subset of data on each node.
          # In future, we may enable caching for validation data.
          try:
              os.makedirs(self.cache_loc, exist_ok=True)
          except Exception as e:
              logger.warning(
                  f"Could not create cache location directory: {e}"
              )
  
      self.dataset = self.get_dataset(*args, **kwargs)
  
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 1 to create a new BaseMultiModalImgText object from inherited base classes: BaseImageDataset with example: obj = BaseMultiModalImgText(opts)