class_docstr: Convert between text-label and text-index 
class_docstr_tok: ["Convert","between","text-label","and","text-index"]
docstr: convert text-label into text-index.
  input:
      text: text labels of each image. [batch_size]
      batch_max_length: max length of text label in the batch. 25 by default
  
  output:
      text : the input of attention decoder. [batch_size x (max_length+2)] +1 for [GO] token and +1 for [s] token.
          text[:, 0] is [GO] token and text is padded with [GO] token after [s] token.
      length : the length of output of attention decoder, which count [s] token also. [3, 7, ....] [batch_size]
docstr_tok: ["convert","text-label","into","text-index",".","input",":","text",":","text","labels","of","each","image",".","[","batch_size","]","batch_max_length",":","max","length","of","text","label","in","the","batch",".","25","by","default","output",":","text",":","the","input","of","attention","decoder",".","[","batch_size","x","(","max_length+2",")","]","+1","for","[","GO","]","token","and","+1","for","[","s","]","token",".","text","[",":",",","0","]","is","[","GO","]","token","and","text","is","padded","with","[","GO","]","token","after","[","s","]","token",".","length",":","the","length","of","output","of","attention","decoder",",","which","count","[","s","]","token","also",".","[","3",",","7",",","....","]","[","batch_size","]"]
code: def encode(self, text, batch_max_length=25):
      """convert text-label into text-index.
      input:
          text: text labels of each image. [batch_size]
          batch_max_length: max length of text label in the batch. 25 by default
  
      output:
          text : the input of attention decoder. [batch_size x (max_length+2)] +1 for [GO] token and +1 for [s] token.
              text[:, 0] is [GO] token and text is padded with [GO] token after [s] token.
          length : the length of output of attention decoder, which count [s] token also. [3, 7, ....] [batch_size]
      """
      length = [
          len(s) + 1 for s in text
      ]  # +1 for [s] at end of sentence.
      # batch_max_length = max(length) # this is not allowed for multi-gpu setting
      batch_max_length += 1
      # additional +1 for [GO] at first step. batch_text is padded with [GO] token after [s] token.
      batch_text = torch.LongTensor(
          len(text), batch_max_length + 1
      ).fill_(0)
      for i, t in enumerate(text):
          text = list(t)
          text.append("[s]")
          text = [self.dict[char] for char in text]
          batch_text[i][1 : 1 + len(text)] = torch.LongTensor(
              text
          )  # batch_text[:, 0] = [GO] token
      return (batch_text.to(device), torch.IntTensor(length).to(device))
  
imports: import torch
  import pickle
  import numpy
label_desc: Use image node_id 2 for calling the AttnLabelConverter obj's underlying member method code with example usage: obj.encode(text, batch_max_length) and returns: batch_text,  torch