code: def convert_example(
      tokenizer,
      attn_id,
      tgt_type_id=3,
      max_encode_len=512,
      max_decode_len=128,
      is_test=False,
      noise_prob=0.0,
      use_random_noice=False,
  ):
      def warpper(example):
          """convert an example into necessary features"""
          tokens = example["tokens"]
          labels = example["labels"]
          encoded_src = tokenizer(
              tokens,
              max_seq_len=max_encode_len,
              pad_to_max_seq_len=False,
          )
          src_ids, src_sids = (
              encoded_src["input_ids"],
              encoded_src["token_type_ids"],
          )
          src_pids = np.arange(len(src_ids))
  
          if not is_test:
              encoded_tgt = tokenizer(
                  labels,
                  max_seq_len=max_decode_len,
                  pad_to_max_seq_len=False,
              )
              tgt_ids, tgt_sids = (
                  encoded_tgt["input_ids"],
                  encoded_tgt["token_type_ids"],
              )
              tgt_ids = np.array(tgt_ids)
              tgt_sids = np.array(tgt_sids) + tgt_type_id
              tgt_pids = np.arange(len(tgt_ids)) + len(src_ids)
  
          attn_ids = np.ones_like(tgt_ids) * attn_id
          if noise_prob > 0.0:
              tgt_labels = deepcopy(tgt_ids)
              if use_random_noice:
                  noice_ids = np.random.randint(
                      1, len(tokenizer.vocab), size=tgt_ids.shape
                  )
              else:
                  noice_ids = (
                      np.ones_like(tgt_ids) * tokenizer.vocab["[NOISE]"]
                  )
              (pos,) = np.where(np.ones_like(tgt_ids))
              np.random.shuffle(pos)
              pos = pos[: int(noise_prob * len(pos))]
              tgt_ids[pos,] = noice_ids[pos,]
          else:
              tgt_labels = tgt_ids
  
          return [
              np.asarray(item, dtype=np.int64)
              for item in [
                  src_ids,
                  src_pids,
                  src_sids,
                  tgt_ids,
                  tgt_pids,
                  tgt_sids,
                  attn_ids,
                  tgt_labels,
              ]
          ]
  
      return warpper
  
imports: from copy import deepcopy
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: convert_example(tokenizer, attn_id, tgt_type_id, max_encode_len, max_decode_len, is_test, noise_prob, use_random_noice) and returns: warpper, unknown