code: def _get_loss_for_price_based_calibration(
      *,
      prices,
      strikes,
      expiries,
      forwards,
      is_call_options,
      volatility_type,
      approximation_type,
      dtype,
      optimizer_arg_handler,
  ):
      """Creates a loss function to be used in volatility-based calibration."""
  
      def _price_transform(x):
          return tf.math.log1p(x)
  
      scaled_target_values = _price_transform(prices)
  
      @make_val_and_grad_fn
      def loss_function(x):
          """Loss function for the price-based optimization."""
          candidate_alpha = optimizer_arg_handler.get_alpha(x)
          candidate_volvol = optimizer_arg_handler.get_volvol(x)
          candidate_rho = optimizer_arg_handler.get_rho(x)
          candidate_beta = optimizer_arg_handler.get_beta(x)
  
          values = approximations.european_option_price(
              strikes=strikes,
              expiries=expiries,
              forwards=forwards,
              is_call_options=is_call_options,
              alpha=tf.expand_dims(candidate_alpha, axis=-1),
              beta=tf.expand_dims(candidate_beta, axis=-1),
              volvol=tf.expand_dims(candidate_volvol, axis=-1),
              rho=tf.expand_dims(candidate_rho, axis=-1),
              volatility_type=volatility_type,
              approximation_type=approximation_type,
              dtype=dtype,
          )
  
          scaled_values = _price_transform(values)
          return tf.math.reduce_mean(
              (scaled_values - scaled_target_values) ** 2, axis=-1
          )
  
      return loss_function
  
imports: from typing import Callable, Tuple
  import tensorflow.compat.v2
  from tf_quant_finance import black_scholes
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.black_scholes.implied_vol_utils import UnderlyingDistribution
  from tf_quant_finance.math import make_val_and_grad_fn
  from tf_quant_finance.math import optimizer
  from tf_quant_finance.models.sabr import approximations
  from tf_quant_finance.models.sabr.approximations.implied_volatility import SabrApproximationType
  from tf_quant_finance.models.sabr.approximations.implied_volatility import SabrImpliedVolatilityType
label_desc: Use image node_id 3 for calling a global function with example usage: _get_loss_for_price_based_calibration() and returns: loss_function, tf, tf