code: def mask_prob(p, onehot_eos, finished):
      is_finished = paddle.cast(
          paddle.reshape(finished, [-1, 1]) != 0, "float32"
      )
      p = (
          is_finished
          * (1.0 - paddle.cast(onehot_eos, "float32"))
          * -9999.0
          + (1.0 - is_finished) * p
      )
      return p
  
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 4 for calling a global function with example usage: mask_prob(p, onehot_eos, finished) and returns: p