class_docstr: Multi-layer BiLSTM model for language detecting. A recreation of "A reproduction of Apple's bi-directional LSTM models
  for language identification in short strings." (Toftrup et al 2021)
  
  Arxiv: https://arxiv.org/abs/2102.06282
  GitHub: https://github.com/AU-DIS/LSTM_langid
  
  This class is similar to https://github.com/AU-DIS/LSTM_langid/blob/main/src/LSTMLID.py
code: def __init__(
      self,
      char_to_idx,
      tag_to_idx,
      num_layers,
      embedding_dim,
      hidden_dim,
      batch_size=64,
      weights=None,
      dropout=0.0,
      lang_subset=None,
  ):
      super(LangIDBiLSTM, self).__init__()
      self.num_layers = num_layers
      self.embedding_dim = embedding_dim
      self.hidden_dim = hidden_dim
      self.char_to_idx = char_to_idx
      self.vocab_size = len(char_to_idx)
      self.tag_to_idx = tag_to_idx
      self.idx_to_tag = [
          i[1]
          for i in sorted([(v, k) for k, v in self.tag_to_idx.items()])
      ]
      self.lang_subset = lang_subset
      self.padding_idx = char_to_idx["<PAD>"]
      self.tagset_size = len(tag_to_idx)
      self.batch_size = batch_size
      self.loss_train = nn.CrossEntropyLoss(weight=weights)
      self.dropout_prob = dropout
  
      # embeddings for chars
      self.char_embeds = nn.Embedding(
          num_embeddings=self.vocab_size,
          embedding_dim=self.embedding_dim,
          padding_idx=self.padding_idx,
      )
  
      # the bidirectional LSTM
      self.lstm = nn.LSTM(
          self.embedding_dim,
          self.hidden_dim,
          num_layers=self.num_layers,
          bidirectional=True,
          batch_first=True,
      )
  
      # convert output to tag space
      self.hidden_to_tag = nn.Linear(
          self.hidden_dim * 2, self.tagset_size
      )
  
      # dropout layer
      self.dropout = nn.Dropout(p=self.dropout_prob)
  
file_path: stanza/stanza/models/langid/model.py
imports: import os
  import torch
  import torch.nn
label_desc: Use image node_id 1 to create a new LangIDBiLSTM object from inherited base classes: nn with example: obj = LangIDBiLSTM(char_to_idx, tag_to_idx, num_layers, embedding_dim, hidden_dim, batch_size, weights, dropout, lang_subset)