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
      )  # words: List[List[int]], chars: List[List[List[int]]], tags: List[List[List[int]]]
  
      # sort sentences by lens for easy RNN operations
      sentlens = [len(x) for x in batch[0]]
      batch, orig_idx = sort_all(batch, sentlens)
      sentlens = [len(x) for x in batch[0]]
  
      # sort chars by lens for easy char-LM operations
      (
          chars_forward,
          chars_backward,
          charoffsets_forward,
          charoffsets_backward,
          charlens,
      ) = self.process_chars(batch[1])
      chars_sorted, char_orig_idx = sort_all(
          [
              chars_forward,
              chars_backward,
              charoffsets_forward,
              charoffsets_backward,
          ],
          charlens,
      )
      (
          chars_forward,
          chars_backward,
          charoffsets_forward,
          charoffsets_backward,
      ) = chars_sorted
      charlens = [len(sent) for sent in chars_forward]
  
      # sort words by lens for easy char-RNN operations
      batch_words = [w for sent in batch[1] for w in sent]
      wordlens = [len(x) for x in batch_words]
      batch_words, word_orig_idx = sort_all([batch_words], wordlens)
      batch_words = batch_words[0]
      wordlens = [len(x) for x in batch_words]
  
      words = batch[0]
  
      wordchars = get_long_tensor(batch_words, len(wordlens))
      wordchars_mask = torch.eq(wordchars, PAD_ID)
      chars_forward = get_long_tensor(
          chars_forward,
          batch_size,
          pad_id=self.vocab["char"].unit2id(" "),
      )
      chars_backward = get_long_tensor(
          chars_backward,
          batch_size,
          pad_id=self.vocab["char"].unit2id(" "),
      )
      chars = torch.cat(
          [chars_forward.unsqueeze(0), chars_backward.unsqueeze(0)]
      )  # padded forward and backward char idx
      charoffsets = [
          charoffsets_forward,
          charoffsets_backward,
      ]  # idx for forward and backward lm to get word representation
      tags = get_long_tensor(batch[2], batch_size)
  
      return (
          words,
          wordchars,
          wordchars_mask,
          chars,
          tags,
          orig_idx,
          word_orig_idx,
          char_orig_idx,
          sentlens,
          wordlens,
          charlens,
          charoffsets,
      )
  
imports: import random
  import logging
  import torch
  from stanza.models.common.bert_embedding import filter_data
  from stanza.models.common.data import map_to_ids, get_long_tensor, sort_all
  from stanza.models.common.vocab import PAD_ID, VOCAB_PREFIX
  from stanza.models.pos.vocab import CharVocab, CompositeVocab, WordVocab
  from stanza.models.ner.vocab import MultiVocab
  from stanza.models.common.doc import *
  from stanza.models.ner.utils import process_tags, normalize_empty_tags
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: words,  wordchars,  wordchars_mask,  chars,  tags,  orig_idx,  word_orig_idx,  char_orig_idx,  sentlens,  wordlens,  charlens,  charoffsets