neulab/docprompting-conala huggingface dataset:
tf.fill     View source on GitHub    Creates a tensor filled with a scalar value.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.fill  
tf.fill(
    dims, value, name=None
)
 See also tf.ones, tf.zeros, tf.one_hot, tf.eye. This operation creates a tensor of shape dims and fills it with value. For example: 
tf.fill([2, 3], 9)
<tf.Tensor: shape=(2, 3), dtype=int32, numpy=
array([[9, 9, 9],
       [9, 9, 9]], dtype=int32)>
 tf.fill evaluates at graph runtime and supports dynamic shapes based on other runtime tf.Tensors, unlike tf.constant(value, shape=dims), which embeds the value as a Const node.
 


 Args
  dims   A 1-D sequence of non-negative numbers. Represents the shape of the output tf.Tensor. Entries should be of type: int32, int64.  
  value   A value to fill the returned tf.Tensor.  
  name   Optional string. The name of the output tf.Tensor.   
 


 Returns   A tf.Tensor with shape dims and the same dtype as value.  

 


 Raises
  InvalidArgumentError   dims contains negative entries.  
  NotFoundError   dims contains non-integer entries.    Numpy Compatibility Similar to np.full. In numpy, more parameters are supported. Passing a number argument as the shape (np.full(5, value)) is valid in numpy for specifying a 1-D shaped result, while TensorFlow does not support this syntax.
tf.fingerprint     View source on GitHub    Generates fingerprint values.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.fingerprint  
tf.fingerprint(
    data, method='farmhash64', name=None
)
 Generates fingerprint values of data. Fingerprint op considers the first dimension of data as the batch dimension, and output[i] contains the fingerprint value generated from contents in data[i, ...] for all i. Fingerprint op writes fingerprint values as byte arrays. For example, the default method farmhash64 generates a 64-bit fingerprint value at a time. This 8-byte value is written out as an tf.uint8 array of size 8, in little-endian order. For example, suppose that data has data type tf.int32 and shape (2, 3, 4), and that the fingerprint method is farmhash64. In this case, the output shape is (2, 8), where 2 is the batch dimension size of data, and 8 is the size of each fingerprint value in bytes. output[0, :] is generated from 12 integers in data[0, :, :] and similarly output[1, :] is generated from other 12 integers in data[1, :, :]. Note that this op fingerprints the raw underlying buffer, and it does not fingerprint Tensor's metadata such as data type and/or shape. For example, the fingerprint values are invariant under reshapes and bitcasts as long as the batch dimension remain the same: tf.fingerprint(data) == tf.fingerprint(tf.reshape(data, ...))
tf.fingerprint(data) == tf.fingerprint(tf.bitcast(data, ...))
 For string data, one should expect tf.fingerprint(data) != tf.fingerprint(tf.string.reduce_join(data)) in general.
 


 Args
  data   A Tensor. Must have rank 1 or higher.  
  method   A Tensor of type tf.string. Fingerprint method used by this op. Currently available method is farmhash64.  
  name   A name for the operation (optional).   
 


 Returns   A two-dimensional Tensor of type tf.uint8. The first dimension equals to data's first dimension, and the second dimension size depends on the fingerprint algorithm.
tf.foldl     View source on GitHub    foldl on the list of tensors unpacked from elems on dimension 0. (deprecated argument values) 
tf.foldl(
    fn, elems, initializer=None, parallel_iterations=10, back_prop=True,
    swap_memory=False, name=None
)
 Warning: SOME ARGUMENT VALUES ARE DEPRECATED: (back_prop=False). They will be removed in a future version. Instructions for updating: back_prop=False is deprecated. Consider using tf.stop_gradient instead. Instead of: results = tf.foldl(fn, elems, back_prop=False) Use: results = tf.nest.map_structure(tf.stop_gradient, tf.foldl(fn, elems)) This foldl operator repeatedly applies the callable fn to a sequence of elements from first to last. The elements are made of the tensors unpacked from elems on dimension 0. The callable fn takes two tensors as arguments. The first argument is the accumulated value computed from the preceding invocation of fn, and the second is the value at the current position of elems. If initializer is None, elems must contain at least one element, and its first element is used as the initializer. Suppose that elems is unpacked into values, a list of tensors. The shape of the result tensor is fn(initializer, values[0]).shape`. This method also allows multi-arity elems and output of fn. If elems is a (possibly nested) list or tuple of tensors, then each of these tensors must have a matching first (unpack) dimension. The signature of fn may match the structure of elems. That is, if elems is (t1, [t2, t3, [t4, t5]]), then an appropriate signature for fn is: fn = lambda (t1, [t2, t3, [t4, t5]]):.
 


 Args
  fn   The callable to be performed.  
  elems   A tensor or (possibly nested) sequence of tensors, each of which will be unpacked along their first dimension. The nested sequence of the resulting slices will be the first argument to fn.  
  initializer   (optional) A tensor or (possibly nested) sequence of tensors, as the initial value for the accumulator.  
  parallel_iterations   (optional) The number of iterations allowed to run in parallel.  
  back_prop   (optional) Deprecated. False disables support for back propagation. Prefer using tf.stop_gradient instead.  
  swap_memory   (optional) True enables GPU-CPU memory swapping.  
  name   (optional) Name prefix for the returned tensors.   
 


 Returns   A tensor or (possibly nested) sequence of tensors, resulting from applying fn consecutively to the list of tensors unpacked from elems, from first to last.  

 


 Raises
  TypeError   if fn is not callable.    Example: elems = tf.constant([1, 2, 3, 4, 5, 6])
sum = foldl(lambda a, x: a + x, elems)
# sum == 21
tf.foldr     View source on GitHub    foldr on the list of tensors unpacked from elems on dimension 0. (deprecated argument values) 
tf.foldr(
    fn, elems, initializer=None, parallel_iterations=10, back_prop=True,
    swap_memory=False, name=None
)
 Warning: SOME ARGUMENT VALUES ARE DEPRECATED: (back_prop=False). They will be removed in a future version. Instructions for updating: back_prop=False is deprecated. Consider using tf.stop_gradient instead. Instead of: results = tf.foldr(fn, elems, back_prop=False) Use: results = tf.nest.map_structure(tf.stop_gradient, tf.foldr(fn, elems)) This foldr operator repeatedly applies the callable fn to a sequence of elements from last to first. The elements are made of the tensors unpacked from elems. The callable fn takes two tensors as arguments. The first argument is the accumulated value computed from the preceding invocation of fn, and the second is the value at the current position of elems. If initializer is None, elems must contain at least one element, and its first element is used as the initializer. Suppose that elems is unpacked into values, a list of tensors. The shape of the result tensor is fn(initializer, values[0]).shape. This method also allows multi-arity elems and output of fn. If elems is a (possibly nested) list or tuple of tensors, then each of these tensors must have a matching first (unpack) dimension. The signature of fn may match the structure of elems. That is, if elems is (t1, [t2, t3, [t4, t5]]), then an appropriate signature for fn is: fn = lambda (t1, [t2, t3, [t4, t5]]):.
 


 Args
  fn   The callable to be performed.  
  elems   A tensor or (possibly nested) sequence of tensors, each of which will be unpacked along their first dimension. The nested sequence of the resulting slices will be the first argument to fn.  
  initializer   (optional) A tensor or (possibly nested) sequence of tensors, as the initial value for the accumulator.  
  parallel_iterations   (optional) The number of iterations allowed to run in parallel.  
  back_prop   (optional) Deprecated. False disables support for back propagation. Prefer using tf.stop_gradient instead.  
  swap_memory   (optional) True enables GPU-CPU memory swapping.  
  name   (optional) Name prefix for the returned tensors.   
 


 Returns   A tensor or (possibly nested) sequence of tensors, resulting from applying fn consecutively to the list of tensors unpacked from elems, from last to first.  

 


 Raises
  TypeError   if fn is not callable.    Example: elems = [1, 2, 3, 4, 5, 6]
sum = foldr(lambda a, x: a + x, elems)
# sum == 21
tf.gather       View source on GitHub    Gather slices from params axis axis according to indices. 
tf.gather(
    params, indices, validate_indices=None, axis=None, batch_dims=0, name=None
)
 Gather slices from params axis axis according to indices. indices must be an integer tensor of any dimension (usually 0-D or 1-D). For 0-D (scalar) indices:  $$\begin{align*} output[p_0, ..., p_{axis-1}, && &&& p_{axis + 1}, ..., p_{N-1}] = \\ params[p_0, ..., p_{axis-1}, && indices, &&& p_{axis + 1}, ..., p_{N-1}] \end{align*}$$  Where N = ndims(params). For 1-D (vector) indices with batch_dims=0:  $$\begin{align*} output[p_0, ..., p_{axis-1}, && &i, &&p_{axis + 1}, ..., p_{N-1}] =\\ params[p_0, ..., p_{axis-1}, && indices[&i], &&p_{axis + 1}, ..., p_{N-1}] \end{align*}$$  In the general case, produces an output tensor where:  $$\begin{align*} output[p_0, &..., p_{axis-1}, & &i_{B}, ..., i_{M-1}, & p_{axis + 1}, &..., p_{N-1}] = \\ params[p_0, &..., p_{axis-1}, & indices[p_0, ..., p_{B-1}, &i_{B}, ..., i_{M-1}], & p_{axis + 1}, &..., p_{N-1}] \end{align*}$$  Where N = ndims(params), M = ndims(indices), and B = batch_dims. Note that params.shape[:batch_dims] must be identical to indices.shape[:batch_dims]. The shape of the output tensor is:  output.shape = params.shape[:axis] + indices.shape[batch_dims:] + params.shape[axis + 1:].  Note that on CPU, if an out of bound index is found, an error is returned. On GPU, if an out of bound index is found, a 0 is stored in the corresponding output value. See also tf.gather_nd.   
 


 Args
  params   The Tensor from which to gather values. Must be at least rank axis + 1.  
  indices   The index Tensor. Must be one of the following types: int32, int64. Must be in range [0, params.shape[axis]).  
  validate_indices   Deprecated, does nothing.  
  axis   A Tensor. Must be one of the following types: int32, int64. The axis in params to gather indices from. Must be greater than or equal to batch_dims. Defaults to the first non-batch dimension. Supports negative indexes.  
  batch_dims   An integer. The number of batch dimensions. Must be less than or equal to rank(indices).  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as params.
tf.get_logger     View source on GitHub    Return TF logger instance.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.get_logger  
tf.get_logger()
tf.get_static_value     View source on GitHub    Returns the constant value of the given tensor, if efficiently calculable.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.get_static_value  
tf.get_static_value(
    tensor, partial=False
)
 This function attempts to partially evaluate the given tensor, and returns its value as a numpy ndarray if this succeeds. Compatibility(V1): If constant_value(tensor) returns a non-None result, it will no longer be possible to feed a different value for tensor. This allows the result of this function to influence the graph that is constructed, and permits static shape optimizations.
 


 Args
  tensor   The Tensor to be evaluated.  
  partial   If True, the returned numpy array is allowed to have partially evaluated values. Values that can't be evaluated will be None.   
 


 Returns   A numpy ndarray containing the constant value of the given tensor, or None if it cannot be calculated.  

 


 Raises
  TypeError   if tensor is not an ops.Tensor.
tf.grad_pass_through     View source on GitHub    Creates a grad-pass-through op with the forward behavior provided in f.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.grad_pass_through  
tf.grad_pass_through(
    f
)
 Use this function to wrap any op, maintaining its behavior in the forward pass, but replacing the original op in the backward graph with an identity. For example: x = tf.Variable(1.0, name="x")
z = tf.Variable(3.0, name="z")

with tf.GradientTape() as tape:
  # y will evaluate to 9.0
  y = tf.grad_pass_through(x.assign)(z**2)
# grads will evaluate to 6.0
grads = tape.gradient(y, z)
 Another example is a 'differentiable' moving average approximation, where gradients are allowed to flow into the last value fed to the moving average, but the moving average is still used for the forward pass: x = ... # Some scalar value
# A moving average object, we don't need to know how this is implemented
moving_average = MovingAverage()
with backprop.GradientTape() as tape:
  # mavg_x will evaluate to the current running average value
  mavg_x = tf.grad_pass_through(moving_average)(x)
grads = tape.gradient(mavg_x, x) # grads will evaluate to 1.0

 


 Args
  f   function f(*x) that returns a Tensor or nested structure of Tensor outputs.   
 


 Returns   A function h(x) which returns the same values as f(x) and whose gradients are the same as those of an identity function.
Module: tf.graph_util Helpers to manipulate a tensor graph in python. Functions import_graph_def(...): Imports the graph from graph_def into the current default Graph. (deprecated arguments)
tf.graph_util.import_graph_def     View source on GitHub    Imports the graph from graph_def into the current default Graph. (deprecated arguments)  View aliases  Main aliases 
tf.import_graph_def Compat aliases for migration See Migration guide for more details. tf.compat.v1.graph_util.import_graph_def, tf.compat.v1.import_graph_def  
tf.graph_util.import_graph_def(
    graph_def, input_map=None, return_elements=None, name=None, op_dict=None,
    producer_op_list=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (op_dict). They will be removed in a future version. Instructions for updating: Please file an issue at https://github.com/tensorflow/tensorflow/issues if you depend on this feature. This function provides a way to import a serialized TensorFlow GraphDef protocol buffer, and extract individual objects in the GraphDef as tf.Tensor and tf.Operation objects. Once extracted, these objects are placed into the current default Graph. See tf.Graph.as_graph_def for a way to create a GraphDef proto.
 


 Args
  graph_def   A GraphDef proto containing operations to be imported into the default graph.  
  input_map   A dictionary mapping input names (as strings) in graph_def to Tensor objects. The values of the named input tensors in the imported graph will be re-mapped to the respective Tensor values.  
  return_elements   A list of strings containing operation names in graph_def that will be returned as Operation objects; and/or tensor names in graph_def that will be returned as Tensor objects.  
  name   (Optional.) A prefix that will be prepended to the names in graph_def. Note that this does not apply to imported function names. Defaults to "import".  
  op_dict   (Optional.) Deprecated, do not use.  
  producer_op_list   (Optional.) An OpList proto with the (possibly stripped) list of OpDefs used by the producer of the graph. If provided, unrecognized attrs for ops in graph_def that have their default value according to producer_op_list will be removed. This will allow some more GraphDefs produced by later binaries to be accepted by earlier binaries.   
 


 Returns   A list of Operation and/or Tensor objects from the imported graph, corresponding to the names in return_elements, and None if returns_elements is None.  

 


 Raises
  TypeError   If graph_def is not a GraphDef proto, input_map is not a dictionary mapping strings to Tensor objects, or return_elements is not a list of strings.  
  ValueError   If input_map, or return_elements contains names that do not appear in graph_def, or graph_def is not well-formed (e.g. it refers to an unknown tensor).
tf.group     View source on GitHub    Create an op that groups multiple operations.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.group  
tf.group(
    *inputs, **kwargs
)
 When this op finishes, all ops in inputs have finished. This op has no output. 
Note: In TensorFlow 2 with eager and/or Autograph, you should not require this method, as code executes in your expected order. Only use tf.group when working with v1-style code or in a graph context such as inside Dataset.map.
 When operating in a v1-style graph context, ops are not executed in the same order as specified in the code; TensorFlow will attempt to execute ops in parallel or in an order convienient to the result it is computing. tf.group allows you to request that one or more results finish before execution continues. tf.group creates a single op (of type NoOp), and then adds appropriate control dependencies. Thus, c = tf.group(a, b) will compute the same graph as this: with tf.control_dependencies([a, b]):
    c = tf.no_op()
 See also tf.tuple and tf.control_dependencies.
 


 Args
  *inputs   Zero or more tensors to group.  
  name   A name for this operation (optional).   
 


 Returns   An Operation that executes all its inputs.  

 


 Raises
  ValueError   If an unknown keyword argument is provided.
tf.guarantee_const Gives a guarantee to the TF runtime that the input tensor is a constant.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.guarantee_const  
tf.guarantee_const(
    input, name=None
)
 The runtime is then free to make optimizations based on this. Only accepts value typed tensors as inputs and rejects resource variable handles as input. Returns the input tensor without modification.
 


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


 Returns   A Tensor. Has the same type as input.
tf.hessians     View source on GitHub    Constructs the Hessian of sum of ys with respect to x in xs. 
tf.hessians(
    ys, xs, gate_gradients=False, aggregation_method=None, name='hessians'
)
 hessians() adds ops to the graph to output the Hessian matrix of ys with respect to xs. It returns a list of Tensor of length len(xs) where each tensor is the Hessian of sum(ys). The Hessian is a matrix of second-order partial derivatives of a scalar tensor (see https://en.wikipedia.org/wiki/Hessian_matrix for more details).
 


 Args
  ys   A Tensor or list of tensors to be differentiated.  
  xs   A Tensor or list of tensors to be used for differentiation.  
  gate_gradients   See gradients() documentation for details.  
  aggregation_method   See gradients() documentation for details.  
  name   Optional name to use for grouping all the gradient ops together. defaults to 'hessians'.   
 


 Returns   A list of Hessian matrices of sum(ys) for each x in xs.  

 


 Raises
  LookupError   if one of the operations between xs and ys does not have a registered gradient function.
tf.histogram_fixed_width     View source on GitHub    Return histogram of values.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.histogram_fixed_width  
tf.histogram_fixed_width(
    values, value_range, nbins=100, dtype=tf.dtypes.int32, name=None
)
 Given the tensor values, this operation returns a rank 1 histogram counting the number of entries in values that fell into every bin. The bins are equal width and determined by the arguments value_range and nbins.
 


 Args
  values   Numeric Tensor.  
  value_range   Shape [2] Tensor of same dtype as values. values <= value_range[0] will be mapped to hist[0], values >= value_range[1] will be mapped to hist[-1].  
  nbins   Scalar int32 Tensor. Number of histogram bins.  
  dtype   dtype for returned histogram.  
  name   A name for this operation (defaults to 'histogram_fixed_width').   
 


 Returns   A 1-D Tensor holding histogram of values.  

 


 Raises
  TypeError   If any unsupported dtype is provided.  
  tf.errors.InvalidArgumentError   If value_range does not satisfy value_range[0] < value_range[1].    Examples: 
# Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)

nbins = 5
value_range = [0.0, 5.0]
new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
hist.numpy()
array([2, 1, 1, 0, 2], dtype=int32)
tf.histogram_fixed_width_bins     View source on GitHub    Bins the given values for use in a histogram.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.histogram_fixed_width_bins  
tf.histogram_fixed_width_bins(
    values, value_range, nbins=100, dtype=tf.dtypes.int32, name=None
)
 Given the tensor values, this operation returns a rank 1 Tensor representing the indices of a histogram into which each element of values would be binned. The bins are equal width and determined by the arguments value_range and nbins.
 


 Args
  values   Numeric Tensor.  
  value_range   Shape [2] Tensor of same dtype as values. values <= value_range[0] will be mapped to hist[0], values >= value_range[1] will be mapped to hist[-1].  
  nbins   Scalar int32 Tensor. Number of histogram bins.  
  dtype   dtype for returned histogram.  
  name   A name for this operation (defaults to 'histogram_fixed_width').   
 


 Returns   A Tensor holding the indices of the binned values whose shape matches values.  

 


 Raises
  TypeError   If any unsupported dtype is provided.  
  tf.errors.InvalidArgumentError   If value_range does not satisfy value_range[0] < value_range[1].    Examples: 
# Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)

nbins = 5
value_range = [0.0, 5.0]
new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
indices.numpy()
array([0, 0, 1, 2, 4, 4], dtype=int32)
tf.identity     View source on GitHub    Return a Tensor with the same shape and contents as input.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.identity  
tf.identity(
    input, name=None
)
 The return value is not the same Tensor as the original, but contains the same values. This operation is fast when used on the same device. For example: 
a = tf.constant([0.78])
a_identity = tf.identity(a)
a.numpy()
array([0.78], dtype=float32)
a_identity.numpy()
array([0.78], dtype=float32)
 Calling tf.identity on a variable will make a Tensor that represents the value of that variable at the time it is called. This is equivalent to calling <variable>.read_value(). 
a = tf.Variable(5)
a_identity = tf.identity(a)
a.assign_add(1)
<tf.Variable ... shape=() dtype=int32, numpy=6>
a.numpy()
6
a_identity.numpy()
5

 


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


 Returns   A Tensor. Has the same type as input.
tf.identity_n Returns a list of tensors with the same shapes and contents as the input  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.identity_n  
tf.identity_n(
    input, name=None
)
 tensors. This op can be used to override the gradient for complicated functions. For example, suppose y = f(x) and we wish to apply a custom function g for backprop such that dx = g(dy). In Python, with tf.get_default_graph().gradient_override_map(
    {'IdentityN': 'OverrideGradientWithG'}):
  y, _ = identity_n([f(x), x])

@tf.RegisterGradient('OverrideGradientWithG')
def ApplyG(op, dy, _):
  return [None, g(dy)]  # Do not backprop to f(x).

 


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


 Returns   A list of Tensor objects. Has the same type as input.