code: def batch_to_ids(batch):
      """
      Converts a batch of tokenized sentences to a tensor representing the sentences with encoded characters
      (len(batch), max sentence length, max word length).
  
      Parameters
      ----------
      batch : ``List[List[str]]``, required
          A list of tokenized sentences.
  
      Returns
      -------
          A tensor of padded character ids.
      """
      instances = []
      indexer = ELMoTokenCharactersIndexer()
      for sentence in batch:
          tokens = [Token(token) for token in sentence]
          field = TextField(tokens, {"character_ids": indexer})
          instance = Instance({"elmo": field})
          instances.append(instance)
  
      dataset = Batch(instances)
      vocab = Vocabulary()
      dataset.index_instances(vocab)
      return dataset.as_tensor_dict()["elmo"]["character_ids"]
  
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import json
  import logging
  import warnings
  import torch
  from torch.nn.modules import Dropout
  import numpy
  from io import open
  from allennlp.common.file_utils import cached_path
  from allennlp.common.checks import ConfigurationError
  from allennlp.common import Params
  from allennlp.common.util import lazy_groups_of
  from allennlp.modules.elmo_lstm import ElmoLstm
  from allennlp.modules.highway import Highway
  from allennlp.modules.scalar_mix import ScalarMix
  from allennlp.nn.util import remove_sentence_boundaries, add_sentence_boundary_token_ids, get_device_of
  from allennlp.data.token_indexers.elmo_indexer import ELMoCharacterMapper, ELMoTokenCharactersIndexer
  from allennlp.data.dataset import Batch
  from allennlp.data import Token, Vocabulary, Instance
  from allennlp.data.fields import TextField
label_desc: Use image node_id 1 for calling a global function with example usage: batch_to_ids(batch) and returns: dataset