code: def str_filt(str_, voc_type):
      alpha_dict = {
          "digit": string.digits,
          "lower": string.digits + string.ascii_lowercase,
          "upper": string.digits + string.ascii_letters,
          "all": string.digits
          + string.ascii_letters
          + string.punctuation,
      }
      if voc_type == "lower":
          str_ = str_.lower()
      for char in str_:
          if char not in alpha_dict[voc_type]:
              str_ = str_.replace(char, "")
      str_ = str_.lower()
      return str_
  
imports: import math
  import warnings
  import numpy
  import paddle
  from paddle import nn
  import string
  from .tps_spatial_transformer import TPSSpatialTransformer
  from .stn import STN
  from .tsrn import GruBlock, mish, UpsampleBLock
  from ppocr.modeling.heads.sr_rensnet_transformer import Transformer, LayerNorm, PositionwiseFeedForward, MultiHeadedAttention
label_desc: Use image node_id 2 for calling a global function with example usage: str_filt(str_, voc_type) and returns: str_