<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I'm using tensorflow 2.10.0.
<ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
lengths = [4, 3, 5, 2]
def g(lengths):
    lengths_transposed = tf.expand_dims(lengths, 1)
    range = tf.range(0, 8, 1)
    range_row = tf.expand_dims(range, 0)
    mask = tf.less(range_row, lengths_transposed)
    result = tf.where(mask, tf.ones([4, 8]), tf.zeros([4, 8]))
    return result
result = g(lengths.copy())
<END_TASK>