code: def cal_predicts_accuracy_srn(
      char_ops, preds, labels, max_text_len, is_debug=False
  ):
      acc_num = 0
      img_num = 0
  
      char_num = char_ops.get_char_num()
  
      total_len = preds.shape[0]
      img_num = int(total_len / max_text_len)
      for i in range(img_num):
          cur_label = []
          cur_pred = []
          for j in range(max_text_len):
              if labels[j + i * max_text_len] != int(char_num - 1):  # 0
                  cur_label.append(labels[j + i * max_text_len][0])
              else:
                  break
  
          for j in range(max_text_len + 1):
              if (
                  j < len(cur_label)
                  and preds[j + i * max_text_len][0] != cur_label[j]
              ):
                  break
              elif j == len(cur_label) and j == max_text_len:
                  acc_num += 1
                  break
              elif j == len(cur_label) and preds[j + i * max_text_len][
                  0
              ] == int(char_num - 1):
                  acc_num += 1
                  break
      acc = acc_num * 1.0 / img_num
      return acc, acc_num, img_num
  
file_path: PaddleHub/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/character.py
imports: import string
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: cal_predicts_accuracy_srn(char_ops, preds, labels, max_text_len, is_debug) and returns: acc,  acc_num,  img_num