code: def greedy_search_infilling(
      model,
      token_ids,
      token_type_ids,
      sos_id,
      eos_id,
      attn_id,
      pad_id,
      unk_id,
      vocab_size,
      max_encode_len=640,
      max_decode_len=100,
      tgt_type_id=3,
  ):
      _, logits, info = model(token_ids, token_type_ids)
      d_batch, d_seqlen = token_ids.shape
      seqlen = paddle.sum(
          paddle.cast(token_ids != 0, "int64"), 1, keepdim=True
      )
      has_stopped = np.zeros([d_batch], dtype=np.bool)
      gen_seq_len = np.zeros([d_batch], dtype=np.int64)
      output_ids = []
  
      past_cache = info["caches"]
  
      cls_ids = paddle.ones([d_batch], dtype="int64") * sos_id
      attn_ids = paddle.ones([d_batch], dtype="int64") * attn_id
      ids = paddle.stack([cls_ids, attn_ids], -1)
      for step in range(max_decode_len):
          bias = gen_bias(token_ids, ids, step)
          pos_ids = paddle.to_tensor(
              np.tile(
                  np.array([[step, step + 1]], dtype=np.int64),
                  [d_batch, 1],
              )
          )
          pos_ids += seqlen
          _, logits, info = model(
              ids,
              paddle.ones_like(ids) * tgt_type_id,
              pos_ids=pos_ids,
              attn_bias=bias,
              past_cache=past_cache,
          )
  
          if logits.shape[-1] > vocab_size:
              logits[:, :, vocab_size:] = 0
          logits[:, :, pad_id] = 0
          logits[:, :, unk_id] = 0
          logits[:, :, attn_id] = 0
  
          gen_ids = paddle.argmax(logits, -1)
  
          past_cached_k, past_cached_v = past_cache
          cached_k, cached_v = info["caches"]
          cached_k = [
              paddle.concat([pk, k[:, :1, :]], 1)
              for pk, k in zip(past_cached_k, cached_k)
          ]  # concat cached
          cached_v = [
              paddle.concat([pv, v[:, :1, :]], 1)
              for pv, v in zip(past_cached_v, cached_v)
          ]
          past_cache = (cached_k, cached_v)
  
          gen_ids = gen_ids[:, 1]
          ids = paddle.stack([gen_ids, attn_ids], 1)
  
          gen_ids = gen_ids.numpy()
          has_stopped |= (gen_ids == eos_id).astype(np.bool)
          gen_seq_len += 1 - has_stopped.astype(np.int64)
          output_ids.append(gen_ids.tolist())
          if has_stopped.all():
              break
      output_ids = np.array(output_ids).transpose([1, 0])
      return output_ids
  
imports: from __future__ import division
  from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import unicode_literals
  import sys
  import re
  import argparse
  import logging
  import json
  import numpy
  from collections import namedtuple
  import paddle
  import paddle.nn
  import numpy
  from paddlenlp.utils.log import logger
label_desc: Use image node_id 2 for calling a global function with example usage: greedy_search_infilling(model, token_ids, token_type_ids, sos_id, eos_id, attn_id, pad_id, unk_id, vocab_size, max_encode_len, max_decode_len, tgt_type_id) and returns: output_ids