class_docstr: COCO Custom Dataset compatible with torch.utils.data.DataLoader.
class_docstr_tok: ["COCO","Custom","Dataset","compatible","with","torch.utils.data.DataLoader","."]
docstr: Returns one data pair (image and caption).
docstr_tok: ["Returns","one","data","pair","(","image","and","caption",")","."]
code: def __getitem__(self, index):
      """Returns one data pair (image and caption)."""
      coco = self.coco
      vocab = self.vocab
      ann_id = self.ids[index]
      caption = coco.anns[ann_id]["caption"]
      img_id = coco.anns[ann_id]["image_id"]
      path = coco.loadImgs(img_id)[0]["file_name"]
  
      image = Image.open(os.path.join(self.root, path)).convert("RGB")
      if self.transform is not None:
          image = self.transform(image)
  
      # Convert caption (string) to word ids.
      tokens = nltk.tokenize.word_tokenize(str(caption).lower())
      caption = []
      caption.append(vocab("<start>"))
      caption.extend([vocab(token) for token in tokens])
      caption.append(vocab("<end>"))
      target = torch.Tensor(caption)
      return image, target
  
file_path: pytorch-tutorial/tutorials/03-advanced/image_captioning/data_loader.py
imports: import torch
  import torchvision.transforms
  import torch.utils.data
  import os
  import pickle
  import numpy
  import nltk
  from PIL import Image
  from build_vocab import Vocabulary
  from pycocotools.coco import COCO
label_desc: Use image node_id 2 for calling the CocoDataset obj's underlying member method code with example usage: obj.__getitem__(index) and returns: image,  target