code: def BuildLMGraph(self, sents):
      dy.renew_cg()
      # initialize the RNN
      init_state = self.builder.initial_state()
      # parameters -> expressions
      R = dy.parameter(self.R)
      bias = dy.parameter(self.bias)
  
      S = vocab.w2i["<s>"]
      # get the cids and masks for each step
      tot_chars = 0
      cids = []
      masks = []
  
      for i in range(len(sents[0])):
          cids.append(
              [
                  (vocab.w2i[sent[i]] if len(sent) > i else S)
                  for sent in sents
              ]
          )
          mask = [(1 if len(sent) > i else 0) for sent in sents]
          masks.append(mask)
          tot_chars += sum(mask)
  
      # start the rnn with "<s>"
      init_ids = cids[0]
      s = init_state.add_input(lookup_batch(self.lookup, init_ids))
  
      losses = []
  
      # feed char vectors into the RNN and predict the next char
      for cid, mask in zip(cids[1:], masks[1:]):
          score = dy.affine_transform([bias, R, s.output()])
          loss = dy.pickneglogsoftmax_batch(score, cid)
          # mask the loss if at least one sentence is shorter
          if mask[-1] != 1:
              mask_expr = dy.inputVector(mask)
              mask_expr = dy.reshape(mask_expr, (1,), len(sents))
              loss = loss * mask_expr
  
          losses.append(loss)
          # update the state of the RNN
          cemb = dy.lookup_batch(self.lookup, cid)
          s = s.add_input(cemb)
  
      return dy.sum_batches(dy.esum(losses)), tot_chars
  
file_path: dynet/examples/tensorboard/rnnlm-batch.py
imports: import dynet
  import time
  import random
  from pycrayon import CrayonClient
  import argparse
  from collections import defaultdict
  from itertools import count
  import sys
  import util
label_desc: Use image node_id 2 for calling the RNNLanguageModel obj's underlying member method code with example usage: obj.BuildLMGraph(sents) and returns: dy,  tot_chars