code: def tensor_repr(swap_data, dtype=None):
      """Creates a tensor representation of the swap."""
      dtype = dtype or tf.float64
      res = dict()
      res["start_date"] = tf.convert_to_tensor(
          swap_data["start_date"], dtype=tf.int32
      )
      res["maturity_date"] = tf.convert_to_tensor(
          swap_data["maturity_date"], dtype=tf.int32
      )
      res["config"] = swap_data["config"]
      res["batch_names"] = swap_data["batch_names"]
      # Update pay_leg
      pay_leg = swap_data["pay_leg"]
      receive_leg = swap_data["receive_leg"]
      if pay_leg.currency != receive_leg.currency:
          raise ValueError(
              "Pay and receive legs should have the same currency"
          )
      if isinstance(pay_leg, coupon_specs.FixedCouponSpecs):
          res["pay_leg"] = fixed_leg_tensor_repr(
              pay_leg, res["config"], dtype
          )
      else:
          res["pay_leg"] = floating_leg_tensor_repr(
              pay_leg, res["config"], dtype
          )
      if isinstance(receive_leg, coupon_specs.FixedCouponSpecs):
          res["receive_leg"] = fixed_leg_tensor_repr(
              receive_leg, res["config"], dtype
          )
      else:
          res["receive_leg"] = floating_leg_tensor_repr(
              receive_leg, res["config"], dtype
          )
      return res
  
imports: from typing import Any, Dict, List, Tuple, Union
  import tensorflow.compat.v2
  from tf_quant_finance import datetime
  from tf_quant_finance.experimental.pricing_platform.framework import utils
  from tf_quant_finance.experimental.pricing_platform.framework.core import business_days
  from tf_quant_finance.experimental.pricing_platform.framework.core import currencies
  from tf_quant_finance.experimental.pricing_platform.framework.core import curve_types
  from tf_quant_finance.experimental.pricing_platform.framework.core import daycount_conventions
  from tf_quant_finance.experimental.pricing_platform.framework.core import rate_indices
  from tf_quant_finance.experimental.pricing_platform.framework.market_data import utils
  from tf_quant_finance.experimental.pricing_platform.framework.rate_instruments import cashflow_streams
  from tf_quant_finance.experimental.pricing_platform.framework.rate_instruments import coupon_specs
  from tf_quant_finance.experimental.pricing_platform.framework.rate_instruments import utils
  from tf_quant_finance.experimental.pricing_platform.instrument_protos import interest_rate_swap_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: tensor_repr(swap_data, dtype) and returns: res