code: def pad_tensors(tensors, pad_values=None, dtype=None, name=None):
      """Pads the innermost dimension of `Tensor`s to a common shape.
  
      Given a list of `Tensor`s of the same `dtype` and with shapes
      `batch_shape_i + [n_i]`, pads the innermost dimension of each tensor to
      `batch_shape_i + [max(n_i)]`. For each tensor `t`, the padding is done with
      values `t[..., -1]`.
  
      ### Example. Pad with the terminal value
      ```python
      x = [[1, 2, 3, 9], [2, 3, 5, 2]]
      y = [4, 5, 8]
      pad_tensors([x, y])
      # Expected: [array([[1, 2, 3, 9], [2, 3, 5, 2]], array([4, 5, 8, 8])]
      ```
  
      ### Example. Pad with user-supplied values
      ```python
      x = [[1, 2, 3, 9], [2, 3, 5, 2]]
      y = [4, 5, 8]
      pad_tensors([x, y], pad_values=10)
      # Expected: [array([[1, 2, 3, 9], [2, 3, 5, 2]], array([4, 5, 8, 10])]
      ```
  
      Args:
        tensors: A list of tensors of the same `dtype` and shapes
          `batch_shape_i + [n_i]`.
        pad_values: An optional scalar `Tensor` or a list of `Tensor`s of shapes
          broadcastable with the corresponding `batch_shape_i` and the same
          `dtype` as `pad_values`. Corresponds to the padded values used for
          `tensors`.
        dtype: The default dtype to use when converting values to `Tensor`s.
          Default value: `None` which means that default dtypes inferred by
            TensorFlow are used.
        name: Python string. The name to give to the ops created by this class.
          Default value: `None` which maps to the default name `pad_tensors`.
      Returns:
        A list of `Tensor`s of shape `batch_shape_i + [max(n_i)]`.
  
      Raises:
        ValueError: If input is not an instance of a list or a tuple.
      """
      if not isinstance(tensors, (tuple, list)):
          raise ValueError(
              f"`tensors` should be a list or a tuple but have type {type(tensors)}"
          )
      if not tensors:
          return []
      name = name or "pad_tensors"
      with tf.name_scope(name):
          t0 = tf.convert_to_tensor(tensors[0], dtype=dtype)
          dtype = dtype or t0.dtype
          tensors = [t0] + [
              tf.convert_to_tensor(t, dtype=dtype) for t in tensors[1:]
          ]
          max_size = tf.reduce_max([tf.shape(t)[-1] for t in tensors])
          padded_tensors = []
          pad_values = _prepare_pad_values(pad_values, tensors, dtype)
          for pad_value, t in zip(pad_values, tensors):
              paddings = (t.shape.rank - 1) * [[0, 0]] + [
                  [0, max_size - tf.shape(t)[-1]]
              ]
              # Padded value has to be a constant
              constant_values = tf.reduce_min(t) - 1
              pad_t = tf.pad(
                  t,
                  paddings,
                  mode="CONSTANT",
                  constant_values=constant_values,
              )
              pad_t = tf.where(
                  pad_t > constant_values, pad_t, pad_value
              )
              padded_tensors.append(pad_t)
      return padded_tensors
  
imports: import tensorflow.compat.v2
  from tf_quant_finance.datetime import date_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: pad_tensors(tensors, pad_values, dtype, name) and returns: padded_tensors, list