code: def _get_payoff_fn(strikes, is_call_options):
      """Constructs the payoff functions."""
      option_signs = (
          tf.cast(is_call_options, dtype=strikes.dtype) * 2 - 1
      )
  
      def payoff(spots):
          """Computes payff for the specified options given the spot grid.
  
          Args:
            spots: Tensor of shape [batch_size, grid_size, 1]. The spot values at some
              time.
  
          Returns:
            Payoffs for exercise at the specified strikes.
          """
          return tf.nn.relu((spots - strikes) * option_signs)
  
      return payoff
  
imports: import tensorflow.compat.v2
label_desc: Use image node_id 2 for calling a global function with example usage: _get_payoff_fn(strikes, is_call_options) and returns: payoff, tf