code: def __getitem__(self, idx):
      if self._dataset_type == "train":
          sample_info = self.annotation_db[idx]
          text_attr = self._get_valid_text_attribute(sample_info)
  
          current_sample = Sample()
          sentence = random.sample(sample_info[text_attr], 1)[0]
          processed_sentence = self.text_processor({"text": sentence})
  
          current_sample.text = processed_sentence["text"]
          if "input_ids" in processed_sentence:
              current_sample.update(processed_sentence)
  
          current_sample.image = self.image_db[idx]["images"][0]
          current_sample.ann_idx = torch.tensor(idx, dtype=torch.long)
      else:
          sample_info = self.annotation_db[idx]
          text_attr = self._get_valid_text_attribute(sample_info)
  
          sample_list = []
          for s_idx, sentence in enumerate(sample_info[text_attr]):
              sentence_sample = Sample()
              processed_sentence = self.text_processor(
                  {"text": sentence}
              )
  
              sentence_sample.raw_text = sentence
              sentence_sample.text = processed_sentence["text"]
              if "input_ids" in processed_sentence:
                  sentence_sample.update(processed_sentence)
  
              sentence_sample.text_index = (
                  idx * self.annotation_db.samples_factor + s_idx
              )
  
              sample_list.append(sentence_sample)
          current_sample = SampleList(sample_list)
  
          current_sample.image = self.image_db[idx]["images"][0]
          current_sample.image_path = self.annotation_db[idx][
              "image_path"
          ]
          current_sample.image_index = idx
  
      current_sample.targets = None  # Dummy for Loss
  
      return current_sample
  
file_path: mmf/mmf/datasets/builders/retrieval/dataset.py
imports: import random
  import torch
  from mmf.common.sample import Sample, SampleList
  from mmf.common.typings import MMFDatasetConfigType
  from mmf.datasets.builders.retrieval.datasets import CaptionsDatabase, COCOAnnotationDatabase, ConceptualCaptionsDatabase
  from mmf.datasets.mmf_dataset import MMFDataset
label_desc: Use image node_id 4 for calling the RetrievalDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: current_sample