neulab/docprompting-conala huggingface dataset:
tf.sparse.slice     View source on GitHub    Slice a SparseTensor based on the start and `size.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.slice, tf.compat.v1.sparse_slice  
tf.sparse.slice(
    sp_input, start, size, name=None
)
 For example, if the input is input_tensor = shape = [2, 7]
[    a   d e  ]
[b c          ]
 Graphically the output tensors are: sparse.slice([0, 0], [2, 4]) = shape = [2, 4]
[    a  ]
[b c    ]

sparse.slice([0, 4], [2, 3]) = shape = [2, 3]
[ d e  ]
[      ]

 


 Args
  sp_input   The SparseTensor to split.  
  start   1-D. tensor represents the start of the slice.  
  size   1-D. tensor represents the size of the slice.  
  name   A name for the operation (optional).   
 


 Returns   A SparseTensor objects resulting from splicing.  

 


 Raises
  TypeError   If sp_input is not a SparseTensor.
tf.sparse.softmax     View source on GitHub    Applies softmax to a batched N-D SparseTensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.softmax, tf.compat.v1.sparse_softmax  
tf.sparse.softmax(
    sp_input, name=None
)
 The inputs represent an N-D SparseTensor with logical shape [..., B, C] (where N >= 2), and with indices sorted in the canonical lexicographic order. This op is equivalent to applying the normal tf.nn.softmax() to each innermost logical submatrix with shape [B, C], but with the catch that the implicitly zero elements do not participate. Specifically, the algorithm is equivalent to: (1) Applies tf.nn.softmax() to a densified view of each innermost submatrix with shape [B, C], along the size-C dimension; (2) Masks out the original implicitly-zero locations; (3) Renormalizes the remaining elements. Hence, the SparseTensor result has exactly the same non-zero indices and shape. Example: # First batch:
# [?   e.]
# [1.  ? ]
# Second batch:
# [e   ? ]
# [e   e ]
shape = [2, 2, 2]  # 3-D SparseTensor
values = np.asarray([[[0., np.e], [1., 0.]], [[np.e, 0.], [np.e, np.e]]])
indices = np.vstack(np.where(values)).astype(np.int64).T

result = tf.sparse.softmax(tf.sparse.SparseTensor(indices, values, shape))
# ...returning a 3-D SparseTensor, equivalent to:
# [?   1.]     [1    ?]
# [1.  ? ] and [.5  .5]
# where ? means implicitly zero.

 


 Args
  sp_input   N-D SparseTensor, where N >= 2.  
  name   optional name of the operation.   
 


 Returns
  output   N-D SparseTensor representing the results.
tf.sparse.split     View source on GitHub    Split a SparseTensor into num_split tensors along axis. 
tf.sparse.split(
    sp_input=None, num_split=None, axis=None, name=None
)
 If the sp_input.dense_shape[axis] is not an integer multiple of num_split each slice starting from 0:shape[axis] % num_split gets extra one dimension. For example: 
indices = [[0, 2], [0, 4], [0, 5], [1, 0], [1, 1]]
values = [1, 2, 3, 4, 5]
t = tf.SparseTensor(indices=indices, values=values, dense_shape=[2, 7])
tf.sparse.to_dense(t)
<tf.Tensor: shape=(2, 7), dtype=int32, numpy=
array([[0, 0, 1, 0, 2, 3, 0],
       [4, 5, 0, 0, 0, 0, 0]], dtype=int32)>
 
output = tf.sparse.split(sp_input=t, num_split=2, axis=1)
tf.sparse.to_dense(output[0])
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
array([[0, 0, 1, 0],
       [4, 5, 0, 0]], dtype=int32)>
tf.sparse.to_dense(output[1])
<tf.Tensor: shape=(2, 3), dtype=int32, numpy=
array([[2, 3, 0],
       [0, 0, 0]], dtype=int32)>
 
output = tf.sparse.split(sp_input=t, num_split=2, axis=0)
tf.sparse.to_dense(output[0])
<tf.Tensor: shape=(1, 7), dtype=int32, numpy=array([[0, 0, 1, 0, 2, 3, 0]],
dtype=int32)>
tf.sparse.to_dense(output[1])
<tf.Tensor: shape=(1, 7), dtype=int32, numpy=array([[4, 5, 0, 0, 0, 0, 0]],
dtype=int32)>
 
output = tf.sparse.split(sp_input=t, num_split=2, axis=-1)
tf.sparse.to_dense(output[0])
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
array([[0, 0, 1, 0],
       [4, 5, 0, 0]], dtype=int32)>
tf.sparse.to_dense(output[1])
<tf.Tensor: shape=(2, 3), dtype=int32, numpy=
array([[2, 3, 0],
       [0, 0, 0]], dtype=int32)>

 


 Args
  sp_input   The SparseTensor to split.  
  num_split   A Python integer. The number of ways to split.  
  axis   A 0-D int32 Tensor. The dimension along which to split. Must be in range [-rank, rank), where rank is the number of dimensions in the input SparseTensor.  
  name   A name for the operation (optional).   
 


 Returns   num_split SparseTensor objects resulting from splitting value.  

 


 Raises
  TypeError   If sp_input is not a SparseTensor.
tf.sparse.to_dense     View source on GitHub    Converts a SparseTensor into a dense tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.to_dense, tf.compat.v1.sparse_tensor_to_dense  
tf.sparse.to_dense(
    sp_input, default_value=None, validate_indices=True, name=None
)
 This op is a convenience wrapper around sparse_to_dense for SparseTensors. For example, if sp_input has shape [3, 5] and non-empty string values: [0, 1]: a
[0, 3]: b
[2, 0]: c
 and default_value is x, then the output will be a dense [3, 5] string tensor with values: [[x a x b x]
 [x x x x x]
 [c x x x x]]
 Indices must be without repeats. This is only tested if validate_indices is True.
 


 Args
  sp_input   The input SparseTensor.  
  default_value   Scalar value to set for indices not specified in sp_input. Defaults to zero.  
  validate_indices   A boolean value. If True, indices are checked to make sure they are sorted in lexicographic order and that there are no repeats.  
  name   A name prefix for the returned tensors (optional).   
 


 Returns   A dense tensor with shape sp_input.dense_shape and values specified by the non-empty values in sp_input. Indices not in sp_input are assigned default_value.  

 


 Raises
  TypeError   If sp_input is not a SparseTensor.
tf.sparse.to_indicator     View source on GitHub    Converts a SparseTensor of ids into a dense bool indicator tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.to_indicator, tf.compat.v1.sparse_to_indicator  
tf.sparse.to_indicator(
    sp_input, vocab_size, name=None
)
 The last dimension of sp_input.indices is discarded and replaced with the values of sp_input. If sp_input.dense_shape = [D0, D1, ..., Dn, K], then output.shape = [D0, D1, ..., Dn, vocab_size], where output[d_0, d_1, ..., d_n, sp_input[d_0, d_1, ..., d_n, k]] = True
 and False elsewhere in output. For example, if sp_input.dense_shape = [2, 3, 4] with non-empty values: [0, 0, 0]: 0
[0, 1, 0]: 10
[1, 0, 3]: 103
[1, 1, 1]: 150
[1, 1, 2]: 149
[1, 1, 3]: 150
[1, 2, 1]: 121
 and vocab_size = 200, then the output will be a [2, 3, 200] dense bool tensor with False everywhere except at positions (0, 0, 0), (0, 1, 10), (1, 0, 103), (1, 1, 149), (1, 1, 150),
(1, 2, 121).
 Note that repeats are allowed in the input SparseTensor. This op is useful for converting SparseTensors into dense formats for compatibility with ops that expect dense tensors. The input SparseTensor must be in row-major order.
 


 Args
  sp_input   A SparseTensor with values property of type int32 or int64.  
  vocab_size   A scalar int64 Tensor (or Python int) containing the new size of the last dimension, all(0 <= sp_input.values < vocab_size).  
  name   A name prefix for the returned tensors (optional)   
 


 Returns   A dense bool indicator tensor representing the indices with specified value.  

 


 Raises
  TypeError   If sp_input is not a SparseTensor.
tf.sparse.transpose     View source on GitHub    Transposes a SparseTensor  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.transpose, tf.compat.v1.sparse_transpose  
tf.sparse.transpose(
    sp_input, perm=None, name=None
)
 The returned tensor's dimension i will correspond to the input dimension perm[i]. If perm is not given, it is set to (n-1...0), where n is the rank of the input tensor. Hence by default, this operation performs a regular matrix transpose on 2-D input Tensors. For example, if sp_input has shape [4, 5] and indices / values: [0, 3]: b
[0, 1]: a
[3, 1]: d
[2, 0]: c
 then the output will be a SparseTensor of shape [5, 4] and indices / values: [0, 2]: c
[1, 0]: a
[1, 3]: d
[3, 0]: b

 


 Args
  sp_input   The input SparseTensor.  
  perm   A permutation of the dimensions of sp_input.  
  name   A name prefix for the returned tensors (optional)   
 


 Returns   A transposed SparseTensor.  

 


 Raises
  TypeError   If sp_input is not a SparseTensor.
tf.SparseTensorSpec     View source on GitHub    Type specification for a tf.sparse.SparseTensor. Inherits From: TypeSpec  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.SparseTensorSpec  
tf.SparseTensorSpec(
    shape=None, dtype=tf.dtypes.float32
)

 


 Args
  shape   The dense shape of the SparseTensor, or None to allow any dense shape.  
  dtype   tf.DType of values in the SparseTensor.   
 


 Attributes
  dtype   The tf.dtypes.DType specified by this type for the SparseTensor.  
  shape   The tf.TensorShape specified by this type for the SparseTensor.  
  value_type  
   Methods from_value View source 
@classmethod
from_value(
    value
)
 is_compatible_with View source 
is_compatible_with(
    spec_or_value
)
 Returns true if spec_or_value is compatible with this TypeSpec. most_specific_compatible_type View source 
most_specific_compatible_type(
    other
)
 Returns the most specific TypeSpec compatible with self and other.
 


 Args
  other   A TypeSpec.   
 


 Raises
  ValueError   If there is no TypeSpec that is compatible with both self and other.    __eq__ View source 
__eq__(
    other
)
 Return self==value. __ne__ View source 
__ne__(
    other
)
 Return self!=value.
tf.split     View source on GitHub    Splits a tensor value into a list of sub tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.split  
tf.split(
    value, num_or_size_splits, axis=0, num=None, name='split'
)
 See also tf.unstack. If num_or_size_splits is an integer, then value is split along the dimension axis into num_or_size_splits smaller tensors. This requires that value.shape[axis] is divisible by num_or_size_splits. If num_or_size_splits is a 1-D Tensor (or list), then value is split into len(num_or_size_splits) elements. The shape of the i-th element has the same size as the value except along dimension axis where the size is num_or_size_splits[i]. For example: 
x = tf.Variable(tf.random.uniform([5, 30], -1, 1))

# Split `x` into 3 tensors along dimension 1
s0, s1, s2 = tf.split(x, num_or_size_splits=3, axis=1)
tf.shape(s0).numpy()
array([ 5, 10], dtype=int32)

# Split `x` into 3 tensors with sizes [4, 15, 11] along dimension 1
split0, split1, split2 = tf.split(x, [4, 15, 11], 1)
tf.shape(split0).numpy()
array([5, 4], dtype=int32)
tf.shape(split1).numpy()
array([ 5, 15], dtype=int32)
tf.shape(split2).numpy()
array([ 5, 11], dtype=int32)

 


 Args
  value   The Tensor to split.  
  num_or_size_splits   Either an integer indicating the number of splits along axis or a 1-D integer Tensor or Python list containing the sizes of each output tensor along axis. If a scalar, then it must evenly divide value.shape[axis]; otherwise the sum of sizes along the split axis must match that of the value.  
  axis   An integer or scalar int32 Tensor. The dimension along which to split. Must be in the range [-rank(value), rank(value)). Defaults to 0.  
  num   Optional, used to specify the number of outputs when it cannot be inferred from the shape of size_splits.  
  name   A name for the operation (optional).   
 


 Returns   if num_or_size_splits is a scalar returns a list of num_or_size_splits Tensor objects; if num_or_size_splits is a 1-D Tensor returns num_or_size_splits.get_shape[0] Tensor objects resulting from splitting value.  

 


 Raises
  ValueError   If num is unspecified and cannot be inferred.
tf.squeeze     View source on GitHub    Removes dimensions of size 1 from the shape of a tensor. 
tf.squeeze(
    input, axis=None, name=None
)
 Given a tensor input, this operation returns a tensor of the same type with all dimensions of size 1 removed. If you don't want to remove all size 1 dimensions, you can remove specific size 1 dimensions by specifying axis. For example: # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
tf.shape(tf.squeeze(t))  # [2, 3]
 Or, to remove specific size 1 dimensions: # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
tf.shape(tf.squeeze(t, [2, 4]))  # [1, 2, 3, 1]
 Unlike the older op tf.compat.v1.squeeze, this op does not accept a deprecated squeeze_dims argument. 
Note: if input is a tf.RaggedTensor, then this operation takes O(N) time, where N is the number of elements in the squeezed dimensions.

 


 Args
  input   A Tensor. The input to squeeze.  
  axis   An optional list of ints. Defaults to []. If specified, only squeezes the dimensions listed. The dimension index starts at 0. It is an error to squeeze a dimension that is not 1. Must be in the range [-rank(input), rank(input)). Must be specified if input is a RaggedTensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input. Contains the same data as input, but has one or more dimensions of size 1 removed.  

 


 Raises
  ValueError   The input cannot be converted to a tensor, or the specified axis cannot be squeezed.
tf.stack     View source on GitHub    Stacks a list of rank-R tensors into one rank-(R+1) tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.stack  
tf.stack(
    values, axis=0, name='stack'
)
 See also tf.concat, tf.tile, tf.repeat. Packs the list of tensors in values into a tensor with rank one higher than each tensor in values, by packing them along the axis dimension. Given a list of length N of tensors of shape (A, B, C); if axis == 0 then the output tensor will have the shape (N, A, B, C). if axis == 1 then the output tensor will have the shape (A, N, B, C). Etc. For example: 
x = tf.constant([1, 4])
y = tf.constant([2, 5])
z = tf.constant([3, 6])
tf.stack([x, y, z])
<tf.Tensor: shape=(3, 2), dtype=int32, numpy=
array([[1, 4],
       [2, 5],
       [3, 6]], dtype=int32)>
tf.stack([x, y, z], axis=1)
<tf.Tensor: shape=(2, 3), dtype=int32, numpy=
array([[1, 2, 3],
       [4, 5, 6]], dtype=int32)>
 This is the opposite of unstack. The numpy equivalent is np.stack 
np.array_equal(np.stack([x, y, z]), tf.stack([x, y, z]))
True

 


 Args
  values   A list of Tensor objects with the same shape and type.  
  axis   An int. The axis to stack along. Defaults to the first dimension. Negative values wrap around, so the valid range is [-(R+1), R+1).  
  name   A name for this operation (optional).   
 


 Returns
  output   A stacked Tensor with the same type as values.   
 


 Raises
  ValueError   If axis is out of the range [-(R+1), R+1).
tf.stop_gradient Stops gradient computation.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.stop_gradient  
tf.stop_gradient(
    input, name=None
)
 When executed in a graph, this op outputs its input tensor as-is. When building ops to compute gradients, this op prevents the contribution of its inputs to be taken into account. Normally, the gradient generator adds ops to a graph to compute the derivatives of a specified 'loss' by recursively finding out inputs that contributed to its computation. If you insert this op in the graph it inputs are masked from the gradient generator. They are not taken into account for computing gradients. This is useful any time you want to compute a value with TensorFlow but need to pretend that the value was a constant. Some examples include:  The EM algorithm where the M-step should not involve backpropagation through the output of the E-step. Contrastive divergence training of Boltzmann machines where, when differentiating the energy function, the training must not backpropagate through the graph that generated the samples from the model. Adversarial training, where no backprop should happen through the adversarial example generation process. 
 


 Args
  input   A Tensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
Module: tf.strings Operations for working with string Tensors. Functions as_string(...): Converts each entry in the given tensor to strings. bytes_split(...): Split string elements of input into bytes. format(...): Formats a string template using a list of tensors. join(...): Perform element-wise concatenation of a list of string tensors. length(...): String lengths of input. lower(...): Converts all uppercase characters into their respective lowercase replacements. ngrams(...): Create a tensor of n-grams based on data. reduce_join(...): Joins all strings into a single string, or joins along an axis. regex_full_match(...): Check if the input matches the regex pattern. regex_replace(...): Replace elements of input matching regex pattern with rewrite. split(...): Split elements of input based on sep into a RaggedTensor. strip(...): Strip leading and trailing whitespaces from the Tensor. substr(...): Return substrings from Tensor of strings. to_hash_bucket(...): Converts each string in the input Tensor to its hash mod by a number of buckets. to_hash_bucket_fast(...): Converts each string in the input Tensor to its hash mod by a number of buckets. to_hash_bucket_strong(...): Converts each string in the input Tensor to its hash mod by a number of buckets. to_number(...): Converts each string in the input Tensor to the specified numeric type. unicode_decode(...): Decodes each string in input into a sequence of Unicode code points. unicode_decode_with_offsets(...): Decodes each string into a sequence of code points with start offsets. unicode_encode(...): Encodes each sequence of Unicode code points in input into a string. unicode_script(...): Determine the script codes of a given tensor of Unicode integer code points. unicode_split(...): Splits each string in input into a sequence of Unicode code points. unicode_split_with_offsets(...): Splits each string into a sequence of code points with start offsets. unicode_transcode(...): Transcode the input text from a source encoding to a destination encoding. unsorted_segment_join(...): Joins the elements of inputs based on segment_ids. upper(...): Converts all lowercase characters into their respective uppercase replacements.
tf.strings.as_string Converts each entry in the given tensor to strings.  View aliases  Main aliases 
tf.as_string Compat aliases for migration See Migration guide for more details. tf.compat.v1.as_string, tf.compat.v1.dtypes.as_string, tf.compat.v1.strings.as_string  
tf.strings.as_string(
    input, precision=-1, scientific=False, shortest=False, width=-1,
    fill='', name=None
)
 Supports many numeric types and boolean. For Unicode, see the https://www.tensorflow.org/tutorials/representation/unicode tutorial. Examples: 
tf.strings.as_string([3, 2])
<tf.Tensor: shape=(2,), dtype=string, numpy=array([b'3', b'2'], dtype=object)>
tf.strings.as_string([3.1415926, 2.71828], precision=2).numpy()
array([b'3.14', b'2.72'], dtype=object)

 


 Args
  input   A Tensor. Must be one of the following types: int8, int16, int32, int64, complex64, complex128, float32, float64, bool.  
  precision   An optional int. Defaults to -1. The post-decimal precision to use for floating point numbers. Only used if precision > -1.  
  scientific   An optional bool. Defaults to False. Use scientific notation for floating point numbers.  
  shortest   An optional bool. Defaults to False. Use shortest representation (either scientific or standard) for floating point numbers.  
  width   An optional int. Defaults to -1. Pad pre-decimal numbers to this width. Applies to both floating point and integer numbers. Only used if width > -1.  
  fill   An optional string. Defaults to "". The value to pad if width > -1. If empty, pads with spaces. Another typical value is '0'. String cannot be longer than 1 character.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.
tf.strings.bytes_split     View source on GitHub    Split string elements of input into bytes.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.strings.bytes_split  
tf.strings.bytes_split(
    input, name=None
)
 Examples: 
tf.strings.bytes_split('hello').numpy()
array([b'h', b'e', b'l', b'l', b'o'], dtype=object)
tf.strings.bytes_split(['hello', '123'])
<tf.RaggedTensor [[b'h', b'e', b'l', b'l', b'o'], [b'1', b'2', b'3']]>
 Note that this op splits strings into bytes, not unicode characters. To split strings into unicode characters, use tf.strings.unicode_split. See also: tf.io.decode_raw, tf.strings.split, tf.strings.unicode_split.
 


 Args
  input   A string Tensor or RaggedTensor: the strings to split. Must have a statically known rank (N).  
  name   A name for the operation (optional).   
 


 Returns   A RaggedTensor of rank N+1: the bytes that make up the source strings.
tf.strings.format     View source on GitHub    Formats a string template using a list of tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.strings.format  
tf.strings.format(
    template, inputs, placeholder='{}', summarize=3, name=None
)
 Formats a string template using a list of tensors, abbreviating tensors by only printing the first and last summarize elements of each dimension (recursively). If formatting only one tensor into a template, the tensor does not have to be wrapped in a list. Example: Formatting a single-tensor template: 
tensor = tf.range(5)
tf.strings.format("tensor: {}, suffix", tensor)
<tf.Tensor: shape=(), dtype=string, numpy=b'tensor: [0 1 2 3 4], suffix'>
 Formatting a multi-tensor template: 
tensor_a = tf.range(2)
tensor_b = tf.range(1, 4, 2)
tf.strings.format("a: {}, b: {}, suffix", (tensor_a, tensor_b))
<tf.Tensor: shape=(), dtype=string, numpy=b'a: [0 1], b: [1 3], suffix'>

 


 Args
  template   A string template to format tensor values into.  
  inputs   A list of Tensor objects, or a single Tensor. The list of tensors to format into the template string. If a solitary tensor is passed in, the input tensor will automatically be wrapped as a list.  
  placeholder   An optional string. Defaults to {}. At each placeholder occurring in the template, a subsequent tensor will be inserted.  
  summarize   An optional int. Defaults to 3. When formatting the tensors, show the first and last summarize entries of each tensor dimension (recursively). If set to -1, all elements of the tensor will be shown.  
  name   A name for the operation (optional).   
 


 Returns   A scalar Tensor of type string.  

 


 Raises
  ValueError   if the number of placeholders does not match the number of inputs.
tf.strings.join     View source on GitHub    Perform element-wise concatenation of a list of string tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.string_join, tf.compat.v1.strings.join  
tf.strings.join(
    inputs, separator='', name=None
)
 Given a list of string tensors of same shape, performs element-wise concatenation of the strings of the same index in all tensors. 
tf.strings.join(['abc','def']).numpy()
b'abcdef'
tf.strings.join([['abc','123'],
                 ['def','456'],
                 ['ghi','789']]).numpy()
array([b'abcdefghi', b'123456789'], dtype=object)
tf.strings.join([['abc','123'],
                 ['def','456']],
                 separator=" ").numpy()
array([b'abc def', b'123 456'], dtype=object)

 


 Args
  inputs   A list of tf.Tensor objects of same size and tf.string dtype.  
  separator   A string added between each string being joined.  
  name   A name for the operation (optional).   
 


 Returns   A tf.string tensor.