def constant_value_as_shape(tensor):  
shape = tf.get_static_value(tensor)<EOL>if shape is not None:<EOL><INDENT>return [None if dim == -<NUM_LIT:1> else dim for dim in shape]<EOL><DEDENT>return tensor_util.constant_value_as_shape(tensor)<EOL>
A version of `constant_value()` that returns a `TensorShape`.

    This version should be used when a constant tensor value is
    interpreted as a (possibly partial) shape, e.g. in the shape
    function for `tf.reshape()`. By explicitly requesting a
    `TensorShape` as the return value, it is possible to represent
    unknown dimensions; by contrast, `constant_value()` is
    all-or-nothing.

    Args:
      tensor: The rank-0 or rank-1 Tensor to be evaluated.

    Returns:
      A `TensorShape` based on the constant value of the given `tensor`.

    Raises:
      ValueError: If the shape is rank-0 and is not statically known to be -1.