parameters: (t)
docstring: Create a structured tensor with the shape of a dense tensor.
docstring_summary: Create a structured tensor with the shape of a dense tensor.
docstring_tokens: Create a structured tensor with the shape of a dense tensor .
function: def _structured_tensor_from_dense_tensor(t):
    """Create a structured tensor with the shape of a dense tensor."""
    # Note: If a tensor will have rank 0,
    # it either has a fully defined shape or has unknown rank.
    if t.shape.is_fully_defined():
      return StructuredTensor.from_fields({}, shape=t.shape)
    elif t.shape.rank is None:
      raise ValueError("Can't build StructuredTensor w/ unknown rank")
    elif t.shape.rank == 1:
      return StructuredTensor.from_fields({}, shape=t.shape,
                                          nrows=array_ops.shape(t)[0])
    else:
      rt = ragged_tensor.RaggedTensor.from_tensor(t)
      return _structured_tensor_from_row_partitions(t.shape,
                                                    rt._nested_row_partitions)
function_tokens: def _structured_tensor_from_dense_tensor ( t ) : # Note: If a tensor will have rank 0, # it either has a fully defined shape or has unknown rank. if t . shape . is_fully_defined ( ) : return StructuredTensor . from_fields ( { } , shape = t . shape ) elif t . shape . rank is None : raise ValueError ( "Can't build StructuredTensor w/ unknown rank" ) elif t . shape . rank == 1 : return StructuredTensor . from_fields ( { } , shape = t . shape , nrows = array_ops . shape ( t ) [ 0 ] ) else : rt = ragged_tensor . RaggedTensor . from_tensor ( t ) return _structured_tensor_from_row_partitions ( t . shape , rt . _nested_row_partitions )