code: def get_curve(dtype, ext_discount):
      valuation_date = dates.convert_to_date_tensor([(2020, 1, 1)])
  
      curve_dates = valuation_date + dates.periods.years([0, 1, 2])
      curve_rates = np.array([0.0, 0.01, 0.02], dtype=np.float64)
  
      def my_discount_function(idates):
          idates = dates.convert_to_date_tensor(idates)
          curve_times = dates.daycount_actual_365_fixed(
              start_date=valuation_date,
              end_date=curve_dates,
              dtype=dtype,
          )
          itimes = dates.daycount_actual_365_fixed(
              start_date=valuation_date, end_date=idates, dtype=dtype
          )
          irates = tff.math.interpolation.linear.interpolate(
              itimes, curve_times, curve_rates, dtype=dtype
          )
          return tf.math.exp(-irates * itimes)
  
      if ext_discount:
          fn = my_discount_function
          return instruments.ratecurve_from_discounting_function(
              fn, dtype
          )
      else:
          curve = instruments.RateCurve(
              curve_dates,
              curve_rates,
              valuation_date=valuation_date,
              dtype=np.float64,
          )
          return curve
  
file_path: tf-quant-finance/tf_quant_finance/experimental/instruments/rate_curve_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 1 for calling a global function with example usage: get_curve(dtype, ext_discount) and returns: tf, instruments, curve