code: def _get_value_modifier(is_american, payoff_fn):
      """Constructs the value modifier for american style exercise."""
  
      def modifier(values, spots):
          immediate_exercise_value = payoff_fn(spots)
          return tf.where(
              is_american,
              tf.math.maximum(immediate_exercise_value, values),
              values,
          )
  
      return modifier
  
imports: import tensorflow.compat.v2
label_desc: Use image node_id 3 for calling a global function with example usage: _get_value_modifier(is_american, payoff_fn) and returns: modifier, tf