neulab/docprompting-conala huggingface dataset:
tf.ragged.boolean_mask     View source on GitHub    Applies a boolean mask to data without flattening the mask dimensions.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.boolean_mask  
tf.ragged.boolean_mask(
    data, mask, name=None
)
 Returns a potentially ragged tensor that is formed by retaining the elements in data where the corresponding value in mask is True.  
output[a1...aA, i, b1...bB] = data[a1...aA, j, b1...bB] Where j is the ith True entry of mask[a1...aA].
  Note that output preserves the mask dimensions a1...aA; this differs from tf.boolean_mask, which flattens those dimensions.
 


 Args
  data   A potentially ragged tensor.  
  mask   A potentially ragged boolean tensor. mask's shape must be a prefix of data's shape. rank(mask) must be known statically.  
  name   A name prefix for the returned tensor (optional).   
 


 Returns   A potentially ragged tensor that is formed by retaining the elements in data where the corresponding value in mask is True.  
rank(output) = rank(data). 
output.ragged_rank = max(data.ragged_rank, rank(mask) - 1). 

 

 


 Raises
  ValueError   if rank(mask) is not known statically; or if mask.shape is not a prefix of data.shape.    Examples: 
# Aliases for True & False so data and mask line up.
T, F = (True, False)
 
tf.ragged.boolean_mask(  # Mask a 2D Tensor.
    data=[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
    mask=[[T, F, T], [F, F, F], [T, F, F]]).to_list()
[[1, 3], [], [7]]
 
tf.ragged.boolean_mask(  # Mask a 2D RaggedTensor.
    tf.ragged.constant([[1, 2, 3], [4], [5, 6]]),
    tf.ragged.constant([[F, F, T], [F], [T, T]])).to_list()
[[3], [], [5, 6]]
 
tf.ragged.boolean_mask(  # Mask rows of a 2D RaggedTensor.
    tf.ragged.constant([[1, 2, 3], [4], [5, 6]]),
    tf.ragged.constant([True, False, True])).to_list()
[[1, 2, 3], [5, 6]]
tf.ragged.constant     View source on GitHub    Constructs a constant RaggedTensor from a nested Python list.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.constant  
tf.ragged.constant(
    pylist, dtype=None, ragged_rank=None, inner_shape=None, name=None,
    row_splits_dtype=tf.dtypes.int64
)
 Example: 
tf.ragged.constant([[1, 2], [3], [4, 5, 6]])
<tf.RaggedTensor [[1, 2], [3], [4, 5, 6]]>
 All scalar values in pylist must have the same nesting depth K, and the returned RaggedTensor will have rank K. If pylist contains no scalar values, then K is one greater than the maximum depth of empty lists in pylist. All scalar values in pylist must be compatible with dtype.
 


 Args
  pylist   A nested list, tuple or np.ndarray. Any nested element that is not a list, tuple or np.ndarray must be a scalar value compatible with dtype.  
  dtype   The type of elements for the returned RaggedTensor. If not specified, then a default is chosen based on the scalar values in pylist.  
  ragged_rank   An integer specifying the ragged rank of the returned RaggedTensor. Must be nonnegative and less than K. Defaults to max(0, K - 1) if inner_shape is not specified. Defaults to max(0, K - 1 - len(inner_shape)) if inner_shape is specified.  
  inner_shape   A tuple of integers specifying the shape for individual inner values in the returned RaggedTensor. Defaults to () if ragged_rank is not specified. If ragged_rank is specified, then a default is chosen based on the contents of pylist.  
  name   A name prefix for the returned tensor (optional).  
  row_splits_dtype   data type for the constructed RaggedTensor's row_splits. One of tf.int32 or tf.int64.   
 


 Returns   A potentially ragged tensor with rank K and the specified ragged_rank, containing the values from pylist.  

 


 Raises
  ValueError   If the scalar values in pylist have inconsistent nesting depth; or if ragged_rank or inner_shape are incompatible with pylist.
tf.ragged.cross Generates feature cross from a list of tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.cross  
tf.ragged.cross(
    inputs, name=None
)
 The input tensors must have rank=2, and must all have the same number of rows. The result is a RaggedTensor with the same number of rows as the inputs, where result[row] contains a list of all combinations of values formed by taking a single value from each input's corresponding row (inputs[i][row]). Values are combined by joining their strings with 'X'. E.g.: 
tf.ragged.cross([tf.ragged.constant([['a'], ['b', 'c']]),
                 tf.ragged.constant([['d'], ['e']]),
                 tf.ragged.constant([['f'], ['g']])])
<tf.RaggedTensor [[b'a_X_d_X_f'], [b'b_X_e_X_g', b'c_X_e_X_g']]>

 


 Args
  inputs   A list of RaggedTensor or Tensor or SparseTensor.  
  name   Optional name for the op.   
 


 Returns   A 2D RaggedTensor of type string.
tf.ragged.cross_hashed Generates hashed feature cross from a list of tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.cross_hashed  
tf.ragged.cross_hashed(
    inputs, num_buckets=0, hash_key=None, name=None
)
 The input tensors must have rank=2, and must all have the same number of rows. The result is a RaggedTensor with the same number of rows as the inputs, where result[row] contains a list of all combinations of values formed by taking a single value from each input's corresponding row (inputs[i][row]). Values are combined by hashing together their fingerprints. E.g.: 
tf.ragged.cross_hashed([tf.ragged.constant([['a'], ['b', 'c']]),
                        tf.ragged.constant([['d'], ['e']]),
                        tf.ragged.constant([['f'], ['g']])],
                       num_buckets=100)
<tf.RaggedTensor [[78], [66, 74]]>

 


 Args
  inputs   A list of RaggedTensor or Tensor or SparseTensor.  
  num_buckets   A non-negative int that used to bucket the hashed values. If num_buckets != 0, then output = hashed_value % num_buckets.  
  hash_key   Integer hash_key that will be used by the FingerprintCat64 function. If not given, a default key is used.  
  name   Optional name for the op.   
 


 Returns   A 2D RaggedTensor of type int64.
tf.ragged.map_flat_values     View source on GitHub    Applies op to the values of one or more RaggedTensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.map_flat_values  
tf.ragged.map_flat_values(
    op, *args, **kwargs
)
 Replaces any RaggedTensor in args or kwargs with its flat_values tensor, and then calls op. Returns a RaggedTensor that is constructed from the input RaggedTensors' nested_row_splits and the value returned by the op. If the input arguments contain multiple RaggedTensors, then they must have identical nested_row_splits. Examples: 
rt = tf.ragged.constant([[1, 2, 3], [], [4, 5], [6]])
map_flat_values(tf.ones_like, rt).to_list()
[[1, 1, 1], [], [1, 1], [1]]
map_flat_values(tf.multiply, rt, rt).to_list()
[[1, 4, 9], [], [16, 25], [36]]
map_flat_values(tf.add, rt, 5).to_list()
[[6, 7, 8], [], [9, 10], [11]]

 


 Args
  op   The operation that should be applied to the RaggedTensor flat_values. op is typically an element-wise operation (such as math_ops.add), but any operation that preserves the size of the outermost dimension can be used. I.e., shape[0] of the value returned by op must match shape[0] of the RaggedTensors' flat_values tensors.  
  *args   Arguments for op.  
  **kwargs   Keyword arguments for op.   
 


 Returns   A RaggedTensor whose ragged_rank matches the ragged_rank of all input RaggedTensors.  

 


 Raises
  ValueError   If args contains no RaggedTensors, or if the nested_splits of the input RaggedTensors are not identical.
tf.ragged.range     View source on GitHub    Returns a RaggedTensor containing the specified sequences of numbers.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.range  
tf.ragged.range(
    starts, limits=None, deltas=1, dtype=None, name=None,
    row_splits_dtype=tf.dtypes.int64
)
 Each row of the returned RaggedTensor contains a single sequence: ragged.range(starts, limits, deltas)[i] ==
    tf.range(starts[i], limits[i], deltas[i])
 If start[i] < limits[i] and deltas[i] > 0, then output[i] will be an empty list. Similarly, if start[i] > limits[i] and deltas[i] < 0, then output[i] will be an empty list. This behavior is consistent with the Python range function, but differs from the tf.range op, which returns an error for these cases. Examples: 
tf.ragged.range([3, 5, 2]).to_list()
[[0, 1, 2], [0, 1, 2, 3, 4], [0, 1]]
tf.ragged.range([0, 5, 8], [3, 3, 12]).to_list()
[[0, 1, 2], [], [8, 9, 10, 11]]
tf.ragged.range([0, 5, 8], [3, 3, 12], 2).to_list()
[[0, 2], [], [8, 10]]
 The input tensors starts, limits, and deltas may be scalars or vectors. The vector inputs must all have the same size. Scalar inputs are broadcast to match the size of the vector inputs.
 


 Args
  starts   Vector or scalar Tensor. Specifies the first entry for each range if limits is not None; otherwise, specifies the range limits, and the first entries default to 0.  
  limits   Vector or scalar Tensor. Specifies the exclusive upper limits for each range.  
  deltas   Vector or scalar Tensor. Specifies the increment for each range. Defaults to 1.  
  dtype   The type of the elements of the resulting tensor. If not specified, then a value is chosen based on the other args.  
  name   A name for the operation.  
  row_splits_dtype   dtype for the returned RaggedTensor's row_splits tensor. One of tf.int32 or tf.int64.   
 


 Returns   A RaggedTensor of type dtype with ragged_rank=1.
tf.ragged.row_splits_to_segment_ids     View source on GitHub    Generates the segmentation corresponding to a RaggedTensor row_splits.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.row_splits_to_segment_ids  
tf.ragged.row_splits_to_segment_ids(
    splits, name=None, out_type=None
)
 Returns an integer vector segment_ids, where segment_ids[i] == j if splits[j] <= i < splits[j+1]. Example: 
print(tf.ragged.row_splits_to_segment_ids([0, 3, 3, 5, 6, 9]))
 tf.Tensor([0 0 0 2 2 3 4 4 4], shape=(9,), dtype=int64)

 


 Args
  splits   A sorted 1-D integer Tensor. splits[0] must be zero.  
  name   A name prefix for the returned tensor (optional).  
  out_type   The dtype for the return value. Defaults to splits.dtype, or tf.int64 if splits does not have a dtype.   
 


 Returns   A sorted 1-D integer Tensor, with shape=[splits[-1]]  

 


 Raises
  ValueError   If splits is invalid.
tf.ragged.segment_ids_to_row_splits     View source on GitHub    Generates the RaggedTensor row_splits corresponding to a segmentation.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.segment_ids_to_row_splits  
tf.ragged.segment_ids_to_row_splits(
    segment_ids, num_segments=None, out_type=None, name=None
)
 Returns an integer vector splits, where splits[0] = 0 and splits[i] = splits[i-1] + count(segment_ids==i). Example: 
print(tf.ragged.segment_ids_to_row_splits([0, 0, 0, 2, 2, 3, 4, 4, 4]))
tf.Tensor([0 3 3 5 6 9], shape=(6,), dtype=int64)

 


 Args
  segment_ids   A 1-D integer Tensor.  
  num_segments   A scalar integer indicating the number of segments. Defaults to max(segment_ids) + 1 (or zero if segment_ids is empty).  
  out_type   The dtype for the return value. Defaults to segment_ids.dtype, or tf.int64 if segment_ids does not have a dtype.  
  name   A name prefix for the returned tensor (optional).   
 


 Returns   A sorted 1-D integer Tensor, with shape=[num_segments + 1].
tf.ragged.stack     View source on GitHub    Stacks a list of rank-R tensors into one rank-(R+1) RaggedTensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.stack  
tf.ragged.stack(
    values, axis=0, name=None
)
 Given a list of tensors or ragged tensors with the same rank R (R >= axis), returns a rank-R+1 RaggedTensor result such that result[i0...iaxis] is [value[i0...iaxis] for value in values]. Examples: 
# Stacking two ragged tensors.
t1 = tf.ragged.constant([[1, 2], [3, 4, 5]])
t2 = tf.ragged.constant([[6], [7, 8, 9]])
tf.ragged.stack([t1, t2], axis=0)
<tf.RaggedTensor [[[1, 2], [3, 4, 5]], [[6], [7, 8, 9]]]>
tf.ragged.stack([t1, t2], axis=1)
<tf.RaggedTensor [[[1, 2], [6]], [[3, 4, 5], [7, 8, 9]]]>
 
# Stacking two dense tensors with different sizes.
t3 = tf.constant([[1, 2, 3], [4, 5, 6]])
t4 = tf.constant([[5], [6], [7]])
tf.ragged.stack([t3, t4], axis=0)
<tf.RaggedTensor [[[1, 2, 3], [4, 5, 6]], [[5], [6], [7]]]>

 


 Args
  values   A list of tf.Tensor or tf.RaggedTensor. May not be empty. All values must have the same rank and the same dtype; but unlike tf.stack, they can have arbitrary dimension sizes.  
  axis   A python integer, indicating the dimension along which to stack. (Note: Unlike tf.stack, the axis parameter must be statically known.) Negative values are supported only if the rank of at least one values value is statically known.  
  name   A name prefix for the returned tensor (optional).   
 


 Returns   A RaggedTensor with rank R+1. result.ragged_rank=1+max(axis, max(rt.ragged_rank for rt in values])).  

 


 Raises
  ValueError   If values is empty, if axis is out of bounds or if the input tensors have different ranks.
tf.ragged.stack_dynamic_partitions     View source on GitHub    Stacks dynamic partitions of a Tensor or RaggedTensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ragged.stack_dynamic_partitions  
tf.ragged.stack_dynamic_partitions(
    data, partitions, num_partitions, name=None
)
 Returns a RaggedTensor output with num_partitions rows, where the row output[i] is formed by stacking all slices data[j1...jN] such that partitions[j1...jN] = i. Slices of data are stacked in row-major order. If num_partitions is an int (not a Tensor), then this is equivalent to tf.ragged.stack(tf.dynamic_partition(data, partitions, num_partitions)). Example: 
data           = ['a', 'b', 'c', 'd', 'e']
partitions     = [  3,   0,   2,   2,   3]
num_partitions = 5
tf.ragged.stack_dynamic_partitions(data, partitions, num_partitions)
<tf.RaggedTensor [[b'b'], [], [b'c', b'd'], [b'a', b'e'], []]>

 


 Args
  data   A Tensor or RaggedTensor containing the values to stack.  
  partitions   An int32 or int64 Tensor or RaggedTensor specifying the partition that each slice of data should be added to. partitions.shape must be a prefix of data.shape. Values must be greater than or equal to zero, and less than num_partitions. partitions is not required to be sorted.  
  num_partitions   An int32 or int64 scalar specifying the number of partitions to output. This determines the number of rows in output.  
  name   A name prefix for the returned tensor (optional).   
 


 Returns   A RaggedTensor containing the stacked partitions. The returned tensor has the same dtype as data, and its shape is [num_partitions, (D)] + data.shape[partitions.rank:], where (D) is a ragged dimension whose length is the number of data slices stacked for each partition.
tf.RaggedTensorSpec     View source on GitHub    Type specification for a tf.RaggedTensor. Inherits From: TypeSpec  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.RaggedTensorSpec  
tf.RaggedTensorSpec(
    shape=None, dtype=tf.dtypes.float32, ragged_rank=None,
    row_splits_dtype=tf.dtypes.int64, flat_values_spec=None
)

 


 Args
  shape   The shape of the RaggedTensor, or None to allow any shape. If a shape is specified, then all ragged dimensions must have size None.  
  dtype   tf.DType of values in the RaggedTensor.  
  ragged_rank   Python integer, the number of times the RaggedTensor's flat_values is partitioned. Defaults to shape.ndims - 1.  
  row_splits_dtype   dtype for the RaggedTensor's row_splits tensor. One of tf.int32 or tf.int64.  
  flat_values_spec   TypeSpec for flat_value of the RaggedTensor. It shall be provided when the flat_values is a CompositeTensor rather then Tensor. If both dtype and flat_values_spec and are provided, dtype must be the same as flat_values_spec.dtype. (experimental)   
 


 Attributes
  dtype   The tf.dtypes.DType specified by this type for the RaggedTensor. 
rt = tf.ragged.constant([["a"], ["b", "c"]], dtype=tf.string)
tf.type_spec_from_value(rt).dtype
tf.string

 
  flat_values_spec   The TypeSpec of the flat_values of RaggedTensor.  
  ragged_rank   The number of times the RaggedTensor's flat_values is partitioned. Defaults to shape.ndims - 1. 
values = tf.ragged.constant([[1, 2, 3], [4], [5, 6], [7, 8, 9, 10]])
tf.type_spec_from_value(values).ragged_rank
1
 
rt1 = tf.RaggedTensor.from_uniform_row_length(values, 2)
tf.type_spec_from_value(rt1).ragged_rank
2

 
  row_splits_dtype   The tf.dtypes.DType of the RaggedTensor's row_splits. 
rt = tf.ragged.constant([[1, 2, 3], [4]], row_splits_dtype=tf.int64)
tf.type_spec_from_value(rt).row_splits_dtype
tf.int64

 
  shape   The statically known shape of the RaggedTensor. 
rt = tf.ragged.constant([[0], [1, 2]])
tf.type_spec_from_value(rt).shape
TensorShape([2, None])
 
rt = tf.ragged.constant([[[0, 1]], [[1, 2], [3, 4]]], ragged_rank=1)
tf.type_spec_from_value(rt).shape
TensorShape([2, None, 2])

 
  value_type   The Python type for values that are compatible with this TypeSpec. In particular, all values that are compatible with this TypeSpec must be an instance of this 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.
Module: tf.random Public API for tf.random namespace. Modules experimental module: Public API for tf.random.experimental namespace. Classes class Algorithm: An enumeration. class Generator: Random-number generator. Functions all_candidate_sampler(...): Generate the set of all classes. categorical(...): Draws samples from a categorical distribution. create_rng_state(...): Creates a RNG state from an integer or a vector. fixed_unigram_candidate_sampler(...): Samples a set of classes using the provided (fixed) base distribution. gamma(...): Draws shape samples from each of the given Gamma distribution(s). get_global_generator(...): Retrieves the global generator. learned_unigram_candidate_sampler(...): Samples a set of classes from a distribution learned during training. log_uniform_candidate_sampler(...): Samples a set of classes using a log-uniform (Zipfian) base distribution. normal(...): Outputs random values from a normal distribution. poisson(...): Draws shape samples from each of the given Poisson distribution(s). set_global_generator(...): Replaces the global generator with another Generator object. set_seed(...): Sets the global random seed. shuffle(...): Randomly shuffles a tensor along its first dimension. stateless_binomial(...): Outputs deterministic pseudorandom values from a binomial distribution. stateless_categorical(...): Draws deterministic pseudorandom samples from a categorical distribution. stateless_gamma(...): Outputs deterministic pseudorandom values from a gamma distribution. stateless_normal(...): Outputs deterministic pseudorandom values from a normal distribution. stateless_parameterized_truncated_normal(...): Outputs random values from a truncated normal distribution. stateless_poisson(...): Outputs deterministic pseudorandom values from a Poisson distribution. stateless_truncated_normal(...): Outputs deterministic pseudorandom values, truncated normally distributed. stateless_uniform(...): Outputs deterministic pseudorandom values from a uniform distribution. truncated_normal(...): Outputs random values from a truncated normal distribution. uniform(...): Outputs random values from a uniform distribution. uniform_candidate_sampler(...): Samples a set of classes using a uniform base distribution.
tf.random.Algorithm An enumeration.  View aliases  Main aliases 
tf.random.experimental.Algorithm Compat aliases for migration See Migration guide for more details. tf.compat.v1.random.Algorithm, tf.compat.v1.random.experimental.Algorithm 
 


 Class Variables
  PHILOX   tf.random.Algorithm  
  THREEFRY   tf.random.Algorithm
tf.random.all_candidate_sampler     View source on GitHub    Generate the set of all classes.  View aliases  Main aliases 
tf.nn.all_candidate_sampler Compat aliases for migration See Migration guide for more details. tf.compat.v1.nn.all_candidate_sampler, tf.compat.v1.random.all_candidate_sampler  
tf.random.all_candidate_sampler(
    true_classes, num_true, num_sampled, unique, seed=None, name=None
)
 Deterministically generates and returns the set of all possible classes. For testing purposes. There is no need to use this, since you might as well use full softmax or full logistic regression.
 


 Args
  true_classes   A Tensor of type int64 and shape [batch_size, num_true]. The target classes.  
  num_true   An int. The number of target classes per training example.  
  num_sampled   An int. The number of possible classes.  
  unique   A bool. Ignored. unique.  
  seed   An int. An operation-specific seed. Default is 0.  
  name   A name for the operation (optional).   
 


 Returns
  sampled_candidates   A tensor of type int64 and shape [num_sampled]. This operation deterministically returns the entire range [0, num_sampled].  
  true_expected_count   A tensor of type float. Same shape as true_classes. The expected counts under the sampling distribution of each of true_classes. All returned values are 1.0.  
  sampled_expected_count   A tensor of type float. Same shape as sampled_candidates. The expected counts under the sampling distribution of each of sampled_candidates. All returned values are 1.0.
tf.random.categorical     View source on GitHub    Draws samples from a categorical distribution.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.random.categorical  
tf.random.categorical(
    logits, num_samples, dtype=None, seed=None, name=None
)
 Example: # samples has shape [1, 5], where each value is either 0 or 1 with equal
# probability.
samples = tf.random.categorical(tf.math.log([[0.5, 0.5]]), 5)

 


 Args
  logits   2-D Tensor with shape [batch_size, num_classes]. Each slice [i, :] represents the unnormalized log-probabilities for all classes.  
  num_samples   0-D. Number of independent samples to draw for each row slice.  
  dtype   integer type to use for the output. Defaults to int64.  
  seed   A Python integer. Used to create a random seed for the distribution. See tf.random.set_seed for behavior.  
  name   Optional name for the operation.   
 


 Returns   The drawn samples of shape [batch_size, num_samples].
tf.random.create_rng_state Creates a RNG state from an integer or a vector.  View aliases  Main aliases 
tf.random.experimental.create_rng_state Compat aliases for migration See Migration guide for more details. tf.compat.v1.random.create_rng_state, tf.compat.v1.random.experimental.create_rng_state  
tf.random.create_rng_state(
    seed, alg
)
 Example: 
tf.random.create_rng_state(
    1234, "philox")
array([1234,    0,    0])
tf.random.create_rng_state(
    [12, 34], "threefry")
array([12, 34])

 


 Args
  seed   an integer or 1-D numpy array.  
  alg   the RNG algorithm. Can be a string, an Algorithm or an integer.   
 


 Returns   a 1-D numpy array whose size depends on the algorithm.