docstr: Get a batch with index. 
docstr_tok: ["Get","a","batch","with","index","."]
code: def __getitem__(self, key):
      """Get a batch with index."""
      if not isinstance(key, int):
          raise TypeError
      if key < 0 or key >= len(self.data):
          raise IndexError
      batch = self.data[key]
      batch_size = len(batch)
      batch = list(zip(*batch))
      assert len(batch) == 3
  
      # sort all fields by lens for easy RNN operations
      lens = [len(x) for x in batch[0]]
      batch, orig_idx = sort_all(batch, lens)
  
      # convert to tensors
      src = batch[0]
      src = get_long_tensor(src, batch_size)
      src_mask = torch.eq(src, constant.PAD_ID)
      tgt_in = get_long_tensor(batch[1], batch_size)
      tgt_out = get_long_tensor(batch[2], batch_size)
      assert tgt_in.size(1) == tgt_out.size(
          1
      ), "Target input and output sequence sizes do not match."
      return (src, src_mask, tgt_in, tgt_out, orig_idx)
  
file_path: stanza/stanza/models/mwt/data.py
imports: import random
  import numpy
  import os
  from collections import Counter
  import logging
  import torch
  import stanza.models.common.seq2seq_constant
  from stanza.models.common.data import map_to_ids, get_long_tensor, get_float_tensor, sort_all
  from stanza.models.mwt.vocab import Vocab
  from stanza.models.common.doc import Document
label_desc: Use image node_id 5 for calling the DataLoader obj's underlying member method code with example usage: obj.__getitem__(key) and returns: src,  src_mask,  tgt_in,  tgt_out,  orig_idx