<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def length_squared(x, keep_dims=False, name=None, reduction_dim=None):
 """Computes the squared length of x. Args: x: A tensor. keep_dims: If true, reduction does not change the rank of the input. name: Optional name for this op. reduction_dim: The dimension to reduce, by default choose the last one and if no shape is specified guess 1. Returns: The squared length of x. """

  with tf.name_scope(name, 'length_squared', [x]) as scope:
    x = tf.convert_to_tensor(x, name='x')
    if not reduction_dim:
      reduction_dim = _last_index(x, 1)
    return tf.reduce_sum(
        tf.square(x),
        reduction_dim,
        keep_dims=keep_dims,
        name=scope)