class_docstr: This is a generic class for 2D (slice-wise) segmentation datasets.
  
  :param filename_pairs: a list of tuples in the format (input filename,
                         ground truth filename).
  :param slice_axis: axis to make the slicing (default axial).
  :param cache: if the data should be cached in memory or not.
  :param transform: transformations to apply.
class_docstr_tok: ["This","is","a","generic","class","for","2D","(","slice-wise",")","segmentation","datasets",".",":","param","filename_pairs",":","a","list","of","tuples","in","the","format","(","input","filename",",","ground","truth","filename",")",".",":","param","slice_axis",":","axis","to","make","the","slicing","(","default","axial",")",".",":","param","cache",":","if","the","data","should","be","cached","in","memory","or","not",".",":","param","transform",":","transformations","to","apply","."]
docstr: Return the specific index pair slices (input, ground truth).
  
  :param index: slice index.
docstr_tok: ["Return","the","specific","index","pair","slices","(","input",",","ground","truth",")",".",":","param","index",":","slice","index","."]
code: def __getitem__(self, index):
      """Return the specific index pair slices (input, ground truth).
  
      :param index: slice index.
      """
      segpair, segpair_slice = self.indexes[index]
      pair_slice = segpair.get_pair_slice(
          segpair_slice, self.slice_axis
      )
  
      # Consistency with torchvision, returning PIL Image
      # Using the "Float mode" of PIL, the only mode
      # supporting unbounded float32 values
      input_img = Image.fromarray(pair_slice["input"], mode="F")
  
      # Handle unlabeled data
      if pair_slice["gt"] is None:
          gt_img = None
      else:
          gt_img = Image.fromarray(pair_slice["gt"], mode="F")
  
      data_dict = {
          "input": input_img,
          "gt": gt_img,
          "input_metadata": pair_slice["input_metadata"],
          "gt_metadata": pair_slice["gt_metadata"],
      }
  
      if self.transform is not None:
          data_dict = self.transform(data_dict)
  
      return data_dict
  
imports: import os
  import re
  import collections
  from medicaltorch import transforms
  from tqdm import tqdm
  import numpy
  import nibabel
  from torch.utils.data import Dataset
  import torch
  from torch._six import string_classes, int_classes
  from PIL import Image
label_desc: Use image node_id 7 for calling the MRI2DSegmentationDataset obj's underlying member method code with example usage: obj.__getitem__(index) and returns: data_dict