code: def _create_curve_building_tensors(
      float_leg_start_times,
      float_leg_end_times,
      fixed_leg_end_times,
      pv_settlement_times,
  ):
      """Helper function to create tensors needed for curve construction."""
      calc_groups_float = []
      calc_groups_fixed = []
      expiry_times = []
      settle_times_float = []
      settle_times_fixed = []
      num_instruments = len(float_leg_start_times)
      for i in range(num_instruments):
          expiry_times.append(
              tf.math.maximum(
                  float_leg_end_times[i][-1], fixed_leg_end_times[i][-1]
              )
          )
  
          calc_groups_float.append(
              tf.fill(tf.shape(float_leg_start_times[i]), i)
          )
          calc_groups_fixed.append(
              tf.fill(tf.shape(fixed_leg_end_times[i]), i)
          )
          settle_time = pv_settlement_times[i]
          if settle_time.shape.rank > 0:
              settle_time = tf.expand_dims(settle_time, axis=-1)
          # shape [batch_shape, float_leg_start_times[i].shape]
          stf = settle_time + tf.zeros_like(float_leg_start_times[i])
          settle_times_float.append(stf)
          # shape [batch_shape, fixed_leg_end_times[i].shape]
          stf = settle_time + tf.zeros_like(fixed_leg_end_times[i])
          settle_times_fixed.append(stf)
  
      expiry_times = tf.stack(expiry_times, axis=0)
      dtype = expiry_times.dtype
      # Float let groups
      num_groups_float = len(calc_groups_float)  # Number of instruments
      calc_groups_float = tf.concat(calc_groups_float, axis=-1)
      # Shape batch_shape + [num_groups_float, calc_groups_float.shape[0]]
      axis = calc_groups_float.shape.rank - 1
      calc_groups_float_mat = tf.one_hot(
          calc_groups_float, num_groups_float, axis=axis, dtype=dtype
      )
      # Fixed leg groups
      num_groups_fixed = len(calc_groups_fixed)
      calc_groups_fixed = tf.concat(calc_groups_fixed, axis=-1)
      # Shape batch_shape + [num_groups_fixed, calc_groups_fixed.shape[0]]
      axis = calc_groups_fixed.shape.rank - 1
      calc_groups_fixed_mat = tf.one_hot(
          calc_groups_fixed, num_groups_fixed, axis=axis, dtype=dtype
      )
      settle_times_float = tf.concat(settle_times_float, axis=-1)
      settle_times_fixed = tf.concat(settle_times_fixed, axis=-1)
  
      return CurveFittingVars(
          expiry_times=expiry_times,
          calc_groups_float=calc_groups_float_mat,
          calc_groups_fixed=calc_groups_fixed_mat,
          settle_times_float=settle_times_float,
          settle_times_fixed=settle_times_fixed,
      )
  
file_path: tf-quant-finance/tf_quant_finance/rates/swap_curve_fit.py
imports: from typing import List, Callable, Any
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import make_val_and_grad_fn
  from tf_quant_finance.math import optimizer
  from tf_quant_finance.math.interpolation import linear
  from tf_quant_finance.rates import swap_curve_common
label_desc: Use image node_id 5 for calling a global function with example usage: _create_curve_building_tensors(float_leg_start_times, float_leg_end_times, fixed_leg_end_times, pv_settlement_times) and returns: CurveFittingVars