code: def rfft(
      x: Union[tf.Tensor, tf.Variable],
      /,
      *,
      n: Optional[int] = None,
      axis: int = -1,
      norm: Literal["backward", "ortho", "forward"] = "backward",
      out: Optional[Union[tf.Tensor, tf.Variable]] = None,
  ) -> Union[tf.Tensor, tf.Variable]:
      # type cast
      if x.dtype in [tf.complex64, tf.complex128]:
          x = tf.math.real(x)
      if x.dtype not in [tf.float32, tf.float64]:
          x = tf.cast(x, tf.float32)
  
      # axis check
      if not isinstance(axis, int):
          raise ivy.utils.exceptions.IvyError(
              f"Expecting <class 'int'> instead of {type(axis)}"
          )
  
      # axis normalization
      naxis = axis
      if axis < 0:
          naxis = x.ndim + axis
      if naxis < 0 or naxis >= x.ndim:
          raise ivy.utils.exceptions.IvyError(
              f"Axis {axis} is out of bounds for array of dimension {x.ndim}"
          )
      axis = naxis
  
      # n checks
      if n is None:
          n = x.shape[axis]
      if not isinstance(n, int):
          raise ivy.utils.exceptions.IvyError(
              f"Expecting <class 'int'> instead of {type(n)}"
          )
      if n < 1:
          raise ivy.utils.exceptions.IvyError(
              f"Invalid number of FFT data points ({n}) specified."
          )
  
      # norm check & value
      if norm == "backward":
          inv_norm = tf.constant(1, dtype=x.dtype)
      elif norm in ["forward", "ortho"]:
          inv_norm = tf.cast(tf.math.reduce_prod(n), dtype=x.dtype)
          if norm == "ortho":
              inv_norm = tf.math.sqrt(inv_norm)
      else:
          raise ivy.utils.exceptions.IvyError(
              f'Invalid norm value {norm}; should be "backward", "ortho" or "forward".'
          )
      fct = 1 / inv_norm
  
      if x.shape[axis] != n:
          s = list(x.shape)
          if s[axis] > n:
              index = [slice(None)] * len(s)
              index[axis] = slice(0, n)
              x = x[tuple(index)]
          else:
              s[axis] = n - s[axis]
              z = tf.zeros(s, x.dtype)
              x = tf.concat([x, z], axis=axis)
  
      if axis == x.ndim - 1:
          ret = tf.signal.rfft(x, fft_length=None, name=None)
      else:
          x = tf.experimental.numpy.swapaxes(x, axis, -1)
          ret = tf.signal.rfft(x, fft_length=None, name=None)
          ret = tf.experimental.numpy.swapaxes(ret, axis, -1)
  
      ret *= tf.cast(fct, dtype=ret.dtype)
  
      if x.dtype != tf.float64:
          ret = tf.cast(ret, dtype=tf.complex64)
      if ivy.exists(out):
          return ivy.inplace_update(out, ret)
      return ret
  
imports: import math
  from typing import Union, Optional, Tuple, List, Literal, Sequence, Callable
  import tensorflow
  from ivy.func_wrapper import inputs_to_ivy_arrays, output_to_native_arrays, with_unsupported_dtypes, with_supported_dtypes, with_supported_device_and_dtypes
  from ..None import backend_version
  import ivy
  from ivy.functional.ivy.layers import _handle_padding, _get_num_padded_values, _validate_max_pool_params, _depth_max_pooling_helper
  from ivy.functional.ivy.experimental.layers import _padding_ceil_mode, _get_size
label_desc: Use image node_id 45 for calling a global function with example usage: rfft() and returns: ret, ivy