class_docstr: Run a pre-trained bidirectional language model, outputing the activations at each
  layer for weighting together into an ELMo representation (with
  ``allennlp.modules.seq2seq_encoders.Elmo``).  This is a lower level class, useful
  for advanced uses, but most users should use ``allennlp.modules.seq2seq_encoders.Elmo``
  directly.
  
  Parameters
  ----------
  options_file : ``str``
      ELMo JSON options file
  weight_file : ``str``
      ELMo hdf5 weight file
  requires_grad: ``bool``, optional
      If True, compute gradient of ELMo parameters for fine tuning.
  vocab_to_cache : ``List[str]``, optional, (default = 0.5).
      A list of words to pre-compute and cache character convolutions
      for. If you use this option, _ElmoBiLm expects that you pass word
      indices of shape (batch_size, timesteps) to forward, instead
      of character indices. If you use this option and pass a word which
      wasn't pre-cached, this will break.
class_docstr_tok: ["Run","a","pre-trained","bidirectional","language","model",",","outputing","the","activations","at","each","layer","for","weighting","together","into","an","ELMo","representation","(","with","``","allennlp.modules.seq2seq_encoders.Elmo","``",")",".","This","is","a","lower","level","class",",","useful","for","advanced","uses",",","but","most","users","should","use","``","allennlp.modules.seq2seq_encoders.Elmo","``","directly",".","Parameters","--","--","--","--","--","options_file",":","``","str","``","ELMo","JSON","options","file","weight_file",":","``","str","``","ELMo","hdf5","weight","file","requires_grad",":","``","bool","``",",","optional","If","True",",","compute","gradient","of","ELMo","parameters","for","fine","tuning",".","vocab_to_cache",":","``","List","[","str","]","``",",","optional",",","(","default","=","0.5",")",".","A","list","of","words","to","pre-compute","and","cache","character","convolutions","for",".","If","you","use","this","option",",","_ElmoBiLm","expects","that","you","pass","word","indices","of","shape","(","batch_size",",","timesteps",")","to","forward",",","instead","of","character","indices",".","If","you","use","this","option","and","pass","a","word","which","was","n't","pre-cached",",","this","will","break","."]
code: def __init__(
      self,
      options_file,
      weight_file,
      requires_grad=False,
      vocab_to_cache=None,
  ):
      super(_ElmoBiLm, self).__init__()
  
      self._token_embedder = _ElmoCharacterEncoder(
          options_file, weight_file, requires_grad=requires_grad
      )
  
      self._requires_grad = requires_grad
      if requires_grad and vocab_to_cache:
          logging.warning(
              "You are fine tuning ELMo and caching char CNN word vectors. "
              "This behaviour is not guaranteed to be well defined, particularly. "
              "if not all of your inputs will occur in the vocabulary cache."
          )
      # This is an embedding, used to look up cached
      # word vectors built from character level cnn embeddings.
      self._word_embedding = None
      self._bos_embedding = None
      self._eos_embedding = None
      if vocab_to_cache:
          logging.info(
              "Caching character cnn layers for words in vocabulary."
          )
          # This sets 3 attributes, _word_embedding, _bos_embedding and _eos_embedding.
          # They are set in the method so they can be accessed from outside the
          # constructor.
          self.create_cached_cnn_embeddings(vocab_to_cache)
  
      with open(cached_path(options_file), "r") as fin:
          options = json.load(fin)
      if not options["lstm"].get("use_skip_connections"):
          raise ConfigurationError(
              "We only support pretrained biLMs with residual connections"
          )
      self._elmo_lstm = ElmoLstm(
          input_size=options["lstm"]["projection_dim"],
          hidden_size=options["lstm"]["projection_dim"],
          cell_size=options["lstm"]["dim"],
          num_layers=options["lstm"]["n_layers"],
          memory_cell_clip_value=options["lstm"]["cell_clip"],
          state_projection_clip_value=options["lstm"]["proj_clip"],
          requires_grad=requires_grad,
      )
      self._elmo_lstm.load_weights(weight_file)
      # Number of representation layers including context independent layer
      self.num_layers = options["lstm"]["n_layers"] + 1
  
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 to create a new _ElmoBiLm object from inherited base classes: torch.nn with example: obj = _ElmoBiLm(options_file, weight_file, requires_grad, vocab_to_cache)