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]
  
  output:
      text: concatenated text index for CTCLoss.
              [sum(text_lengths)] = [text_index_0 + text_index_1 + ... + text_index_(n - 1)]
      length: length of each text. [batch_size]
docstr_tok: ["convert","text-label","into","text-index",".","input",":","text",":","text","labels","of","each","image",".","[","batch_size","]","output",":","text",":","concatenated","text","index","for","CTCLoss",".","[","sum","(","text_lengths",")","]","=","[","text_index_0","+","text_index_1","+","...","+","text_index_","(","n","-","1",")","]","length",":","length","of","each","text",".","[","batch_size","]"]
code: def encode(self, text):
      """convert text-label into text-index.
      input:
          text: text labels of each image. [batch_size]
  
      output:
          text: concatenated text index for CTCLoss.
                  [sum(text_lengths)] = [text_index_0 + text_index_1 + ... + text_index_(n - 1)]
          length: length of each text. [batch_size]
      """
      if self.character_type == "en":
          text = text.lower()
  
      text_list = []
      for char in text:
          if char not in self.dict:
              continue
          text_list.append(self.dict[char])
      text = np.array(text_list)
      return text
  
imports: import cv2
  import copy
  import numpy
  import math
  import re
  import sys
  import argparse
  import string
  from copy import deepcopy
  from argparse import ArgumentParser, RawDescriptionHelpFormatter
  import yaml
label_desc: Use image node_id 2 for calling the CharacterOps obj's underlying member method code with example usage: obj.encode(text) and returns: text