class_docstr: Convert between text-label and text-index 
class_docstr_tok: ["Convert","between","text-label","and","text-index"]
code: def get_beg_end_flag_idx(self, beg_or_end):
      if self.loss_type == "attention":
          if beg_or_end == "beg":
              idx = np.array(self.dict[self.beg_str])
          elif beg_or_end == "end":
              idx = np.array(self.dict[self.end_str])
          else:
              assert False, (
                  "Unsupport type %s in get_beg_end_flag_idx"
                  % beg_or_end
              )
          return idx
      else:
          err = (
              "error in get_beg_end_flag_idx when using the loss %s"
              % (self.loss_type)
          )
          assert False, err
  
imports: import cv2
  import copy
  import numpy
  import math
  import re
  import sys
  import argparse
  import string
  from copy import deepcopy
label_desc: Use image node_id 5 for calling the CharacterOps obj's underlying member method code with example usage: obj.get_beg_end_flag_idx(beg_or_end) and returns: idx