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: Returns the sample corresponding to the input sample index.
  
  Returned sample is transformed into the size specified by the input.
  
  Args:
      sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index)
  
  Returns:
      A dictionary with `samples` and `targets` as keys corresponding to input and label of
      a sample, respectively.
  
  Shapes:
      The shape of values in output dictionary, output_data, are as follows:
  
      output_data["samples"]["image"]: Shape is [Channels, Height, Width]
      output_data["samples"]["text"]: Shape is
          * [Context_Length] (single caption, as in CLIP datasets)
          * [Num_classes, Num_Captions, Context_length] (multiple captions per class, as in 0-shot Imagenet dataset)
      output_data["samples"]["padding_mask"]: Same as output_data["samples"]["text"]
      output_data["samples"]["max_seq_len"]: Shape is [1]
      output_data["targets"]: Shape is [1]
docstr_tok: ["Returns","the","sample","corresponding","to","the","input","sample","index",".","Returned","sample","is","transformed","into","the","size","specified","by","the","input",".","Args",":","sample_size_and_index",":","Tuple","of","the","form","(","crop_size_h",",","crop_size_w",",","sample_index",")","Returns",":","A","dictionary","with","`","samples","`","and","`","targets","`","as","keys","corresponding","to","input","and","label","of","a","sample",",","respectively",".","Shapes",":","The","shape","of","values","in","output","dictionary",",","output_data",",","are","as","follows",":","output_data","[","``","samples","''","]","[","``","image","''","]",":","Shape","is","[","Channels",",","Height",",","Width","]","output_data","[","``","samples","''","]","[","``","text","''","]",":","Shape","is","*","[","Context_Length","]","(","single","caption",",","as","in","CLIP","datasets",")","*","[","Num_classes",",","Num_Captions",",","Context_length","]","(","multiple","captions","per","class",",","as","in","0-shot","Imagenet","dataset",")","output_data","[","``","samples","''","]","[","``","padding_mask","''","]",":","Same","as","output_data","[","``","samples","''","]","[","``","text","''","]","output_data","[","``","samples","''","]","[","``","max_seq_len","''","]",":","Shape","is","[","1","]","output_data","[","``","targets","''","]",":","Shape","is","[","1","]"]
code: def __getitem__(
      self, sample_size_and_index: Tuple[int, int, int]
  ) -> Mapping[str, Union[Tensor, Mapping[str, Tensor]]]:
      """Returns the sample corresponding to the input sample index.
  
      Returned sample is transformed into the size specified by the input.
  
      Args:
          sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index)
  
      Returns:
          A dictionary with `samples` and `targets` as keys corresponding to input and label of
          a sample, respectively.
  
      Shapes:
          The shape of values in output dictionary, output_data, are as follows:
  
          output_data["samples"]["image"]: Shape is [Channels, Height, Width]
          output_data["samples"]["text"]: Shape is
              * [Context_Length] (single caption, as in CLIP datasets)
              * [Num_classes, Num_Captions, Context_length] (multiple captions per class, as in 0-shot Imagenet dataset)
          output_data["samples"]["padding_mask"]: Same as output_data["samples"]["text"]
          output_data["samples"]["max_seq_len"]: Shape is [1]
          output_data["targets"]: Shape is [1]
      """
      crop_size_h, crop_size_w, img_index = sample_size_and_index
      transform_fn = self.get_augmentation_transforms(
          size=(crop_size_h, crop_size_w)
      )
  
      if self.zero_shot_dataset is not None:
          # read captions and image path from conceptual captions dataset
          # read captions and image path from zero-shot dataset
          (
              input_img,
              captions_str,
              class_label,
          ) = self.get_zero_shot_pair(img_index=img_index)
      else:
          input_img, captions_str, class_label = self.get_dataset_pair(
              img_index=img_index
          )
  
      if input_img is None:
          captions_tensor = torch.zeros(
              size=(self.context_length,), dtype=torch.long
          )
          data = {
              "samples": {
                  "image": torch.zeros(
                      size=(3, crop_size_h, crop_size_w)
                  ),
                  "text": captions_tensor,
                  "padding_mask": (
                      captions_tensor == self.padding_index
                  )
                  if self.padding_index is not None
                  else None,
                  "max_seq_len": self.context_length,
              },
              "targets": -1,
          }
      else:
          (
              img_tensor,
              captions_tensor,
              max_seq_len,
          ) = self._process_img_caption(
              input_img=input_img,
              captions_str=captions_str,
              img_transform_fn=transform_fn,
              zero_shot=self.zero_shot_dataset is not None,
          )
  
          data = {
              "samples": {
                  "image": img_tensor,
                  "text": captions_tensor,
                  "padding_mask": (
                      captions_tensor == self.padding_index
                  )
                  if self.padding_index is not None
                  else None,
                  "max_seq_len": max_seq_len,
              },
              "targets": class_label,
          }
  
      if self.zero_shot_dataset is not None:
          data["zero_shot"] = 1
  
      return data
  
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 12 for calling the BaseMultiModalImgText obj's underlying member method code with example usage: obj.__getitem__(sample_size_and_index) and returns: data