code: def _get_risk_free_rate_from_discount_factor(discount_factor_fn):
      """Returns r(t) given a discount factor function."""
  
      def risk_free_rate_fn(t):
          logdf = lambda x: -tf.math.log(discount_factor_fn(x))
          return math.fwd_gradient(
              logdf,
              t,
              unconnected_gradients=tf.UnconnectedGradients.ZERO,
          )
  
      return risk_free_rate_fn
  
imports: import functools
  from typing import Any, Callable, List, Optional, Union
  import tensorflow.compat.v2
  from tf_quant_finance import black_scholes
  from tf_quant_finance import datetime
  from tf_quant_finance import math
  from tf_quant_finance import types
  from tf_quant_finance.experimental.pricing_platform.framework.market_data import volatility_surface
  from tf_quant_finance.math import interpolation
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math import random
  from tf_quant_finance.models import generic_ito_process
label_desc: Use image node_id 5 for calling a global function with example usage: _get_risk_free_rate_from_discount_factor(discount_factor_fn) and returns: risk_free_rate_fn, math