neulab/docprompting-conala huggingface dataset:
tf.AggregationMethod     View source on GitHub    A class listing aggregation methods used to combine gradients.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.AggregationMethod  Computing partial derivatives can require aggregating gradient contributions. This class lists the various methods that can be used to combine gradients in the graph. The following aggregation methods are part of the stable API for aggregating gradients:  
ADD_N: All of the gradient terms are summed as part of one operation using the "AddN" op (see tf.add_n). This method has the property that all gradients must be ready and buffered separately in memory before any aggregation is performed. 
DEFAULT: The system-chosen default aggregation method.  The following aggregation methods are experimental and may not be supported in future releases:  
EXPERIMENTAL_TREE: Gradient terms are summed in pairs using using the "AddN" op. This method of summing gradients may reduce performance, but it can improve memory utilization because the gradients can be released earlier. 
 


 Class Variables
  ADD_N   0  
  DEFAULT   0  
  EXPERIMENTAL_ACCUMULATE_N   2  
  EXPERIMENTAL_TREE   1
tf.argsort     View source on GitHub    Returns the indices of a tensor that give its sorted order along an axis.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.argsort  
tf.argsort(
    values, axis=-1, direction='ASCENDING', stable=False, name=None
)
 For a 1D tensor, tf.gather(values, tf.argsort(values)) is equivalent to tf.sort(values). For higher dimensions, the output has the same shape as values, but along the given axis, values represent the index of the sorted element in that slice of the tensor at the given position. Usage: import tensorflow as tf
a = [1, 10, 26.9, 2.8, 166.32, 62.3]
b = tf.argsort(a,axis=-1,direction='ASCENDING',stable=False,name=None)
c = tf.keras.backend.eval(b)
# Here, c = [0 3 1 2 5 4]

 


 Args
  values   1-D or higher numeric Tensor.  
  axis   The axis along which to sort. The default is -1, which sorts the last axis.  
  direction   The direction in which to sort the values ('ASCENDING' or 'DESCENDING').  
  stable   If True, equal elements in the original tensor will not be re-ordered in the returned order. Unstable sort is not yet implemented, but will eventually be the default for performance reasons. If you require a stable order, pass stable=True for forwards compatibility.  
  name   Optional name for the operation.   
 


 Returns   An int32 Tensor with the same shape as values. The indices that would sort each slice of the given values along the given axis.  

 


 Raises
  ValueError   If axis is not a constant scalar, or the direction is invalid.
Module: tf.audio Public API for tf.audio namespace. Functions decode_wav(...): Decode a 16-bit PCM WAV file to a float tensor. encode_wav(...): Encode audio data using the WAV file format.
tf.audio.decode_wav Decode a 16-bit PCM WAV file to a float tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.audio.decode_wav  
tf.audio.decode_wav(
    contents, desired_channels=-1, desired_samples=-1, name=None
)
 The -32768 to 32767 signed 16-bit values will be scaled to -1.0 to 1.0 in float. When desired_channels is set, if the input contains fewer channels than this then the last channel will be duplicated to give the requested number, else if the input has more channels than requested then the additional channels will be ignored. If desired_samples is set, then the audio will be cropped or padded with zeroes to the requested length. The first output contains a Tensor with the content of the audio samples. The lowest dimension will be the number of channels, and the second will be the number of samples. For example, a ten-sample-long stereo WAV file should give an output shape of [10, 2].
 


 Args
  contents   A Tensor of type string. The WAV-encoded audio, usually from a file.  
  desired_channels   An optional int. Defaults to -1. Number of sample channels wanted.  
  desired_samples   An optional int. Defaults to -1. Length of audio requested.  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (audio, sample_rate).     audio   A Tensor of type float32.  
  sample_rate   A Tensor of type int32.
tf.audio.encode_wav Encode audio data using the WAV file format.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.audio.encode_wav  
tf.audio.encode_wav(
    audio, sample_rate, name=None
)
 This operation will generate a string suitable to be saved out to create a .wav audio file. It will be encoded in the 16-bit PCM format. It takes in float values in the range -1.0f to 1.0f, and any outside that value will be clamped to that range. audio is a 2-D float Tensor of shape [length, channels]. sample_rate is a scalar Tensor holding the rate to use (e.g. 44100).
 


 Args
  audio   A Tensor of type float32. 2-D with shape [length, channels].  
  sample_rate   A Tensor of type int32. Scalar containing the sample frequency.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.
Module: tf.autodiff Public API for tf.autodiff namespace. Classes class ForwardAccumulator: Computes Jacobian-vector products ("JVP"s) using forward-mode autodiff. class GradientTape: Record operations for automatic differentiation.
Module: tf.autograph Conversion of plain Python into TensorFlow graph code. 
Note: In TensorFlow 2.0, AutoGraph is automatically applied when using tf.function. This module contains lower-level APIs for advanced use.
 For more information, see the AutoGraph guide. By equivalent graph code we mean code that generates a TensorFlow graph when run. The generated graph has the same effects as the original code when executed (for example with tf.function or tf.compat.v1.Session.run). In other words, using AutoGraph can be thought of as running Python in TensorFlow. Modules experimental module: Public API for tf.autograph.experimental namespace. Functions set_verbosity(...): Sets the AutoGraph verbosity level. to_code(...): Returns the source code generated by AutoGraph, as a string. to_graph(...): Converts a Python entity into a TensorFlow graph. trace(...): Traces argument information at compilation time.
Module: tf.autograph.experimental Public API for tf.autograph.experimental namespace. Classes class Feature: This enumeration represents optional conversion options. Functions do_not_convert(...): Decorator that suppresses the conversion of a function. set_loop_options(...): Specifies additional arguments to be passed to the enclosing while_loop.
tf.autograph.experimental.do_not_convert     View source on GitHub    Decorator that suppresses the conversion of a function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.autograph.experimental.do_not_convert  
tf.autograph.experimental.do_not_convert(
    func=None
)

 


 Args
  func   function to decorate.   
 


 Returns   If func is not None, returns a Callable which is equivalent to func, but is not converted by AutoGraph. If func is None, returns a decorator that, when invoked with a single func argument, returns a Callable equivalent to the above case.
tf.autograph.experimental.Feature     View source on GitHub    This enumeration represents optional conversion options.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.autograph.experimental.Feature  These conversion options are experimental. They are subject to change without notice and offer no guarantees. Example Usage optionals= tf.autograph.experimental.Feature.EQUALITY_OPERATORS
@tf.function(experimental_autograph_options=optionals)
def f(i):
  if i == 0:  # EQUALITY_OPERATORS allows the use of == here.
    tf.print('i is zero')

 


 Attributes
  ALL   Enable all features.  
  AUTO_CONTROL_DEPS   Insert of control dependencies in the generated code.  
  ASSERT_STATEMENTS   Convert Tensor-dependent assert statements to tf.Assert.  
  BUILTIN_FUNCTIONS   Convert builtin functions applied to Tensors to their TF counterparts.  
  EQUALITY_OPERATORS   Whether to convert the comparison operators, like equality. This is soon to be deprecated as support is being added to the Tensor class.  
  LISTS   Convert list idioms, like initializers, slices, append, etc.  
  NAME_SCOPES   Insert name scopes that name ops according to context, like the function they were defined in.   
 


 Class Variables
  ALL   tf.autograph.experimental.Feature  
  ASSERT_STATEMENTS   tf.autograph.experimental.Feature  
  AUTO_CONTROL_DEPS   tf.autograph.experimental.Feature  
  BUILTIN_FUNCTIONS   tf.autograph.experimental.Feature  
  EQUALITY_OPERATORS   tf.autograph.experimental.Feature  
  LISTS   tf.autograph.experimental.Feature  
  NAME_SCOPES   tf.autograph.experimental.Feature
tf.autograph.experimental.set_loop_options Specifies additional arguments to be passed to the enclosing while_loop.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.autograph.experimental.set_loop_options  
tf.autograph.experimental.set_loop_options(
    parallel_iterations=UNSPECIFIED, swap_memory=UNSPECIFIED,
    maximum_iterations=UNSPECIFIED, shape_invariants=UNSPECIFIED
)
 The parameters apply to and only to the immediately enclosing loop. It only has effect if the loop is staged as a TF while_loop; otherwise the parameters have no effect. Usage: 
@tf.function(autograph=True)
def f():
  n = 0
  for i in tf.range(10):
    tf.autograph.experimental.set_loop_options(maximum_iterations=3)
    n += 1
  return n
 
@tf.function(autograph=True)
def f():
  v = tf.constant((0,))
  for i in tf.range(3):
    tf.autograph.experimental.set_loop_options(
        shape_invariants=[(v, tf.TensorShape([None]))]
    )
    v = tf.concat((v, [i]), 0)
  return v
 Also see tf.while_loop.
 


 Args
  parallel_iterations   The maximum number of iterations allowed to run in parallel at any given time. Note that this does not guarantee parallel execution.  
  swap_memory   Whether to store intermediate values needed for gradients on the CPU instead of GPU.  
  maximum_iterations   Allows limiting the total number of iterations executed by the loop.  
  shape_invariants   Allows controlling the argument with the same name passed to tf.while_loop. Unlike tf.while_loop, this is a list of (tensor, shape) pairs.
tf.autograph.set_verbosity     View source on GitHub    Sets the AutoGraph verbosity level.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.autograph.set_verbosity  
tf.autograph.set_verbosity(
    level, alsologtostdout=False
)
 Debug logging in AutoGraph More verbose logging is useful to enable when filing bug reports or doing more in-depth debugging. There are two means to control the logging verbosity:  The set_verbosity function The AUTOGRAPH_VERBOSITY environment variable  set_verbosity takes precedence over the environment variable. For example: import os
import tensorflow as tf

os.environ['AUTOGRAPH_VERBOSITY'] = 5
# Verbosity is now 5

tf.autograph.set_verbosity(0)
# Verbosity is now 0

os.environ['AUTOGRAPH_VERBOSITY'] = 1
# No effect, because set_verbosity was already called.
 Logs entries are output to absl's default output, with INFO level. Logs can be mirrored to stdout by using the alsologtostdout argument. Mirroring is enabled by default when Python runs in interactive mode.
 


 Args
  level   int, the verbosity level; larger values specify increased verbosity; 0 means no logging. When reporting bugs, it is recommended to set this value to a larger number, like 10.  
  alsologtostdout   bool, whether to also output log messages to sys.stdout.
tf.autograph.to_code     View source on GitHub    Returns the source code generated by AutoGraph, as a string. 
tf.autograph.to_code(
    entity, recursive=True, experimental_optional_features=None
)
 Example usage: 
def f(x):
  if x < 0:
    x = -x
  return x
tf.autograph.to_code(f)
"...def tf__f(x):..."
 Also see: tf.autograph.to_graph. 
Note: If a function has been decorated with tf.function, pass its underlying Python function, rather than the callable that `tf.function creates:
 
@tf.function
def f(x):
  if x < 0:
    x = -x
  return x
tf.autograph.to_code(f.python_function)
"...def tf__f(x):..."

 


 Args
  entity   Python callable or class to convert.  
  recursive   Whether to recursively convert any functions that the converted function may call.  
  experimental_optional_features   None, a tuple of, or a single tf.autograph.experimental.Feature value.   
 


 Returns   The converted code as string.
tf.autograph.to_graph     View source on GitHub    Converts a Python entity into a TensorFlow graph. 
tf.autograph.to_graph(
    entity, recursive=True, experimental_optional_features=None
)
 Also see: tf.autograph.to_code, tf.function. Unlike tf.function, to_graph is a low-level transpiler that converts Python code to TensorFlow graph code. It does not implement any caching, variable management or create any actual ops, and is best used where greater control over the generated TensorFlow graph is desired. Another difference from tf.function is that to_graph will not wrap the graph into a TensorFlow function or a Python callable. Internally, tf.function uses to_graph. Example usage: 
def f(x):
  if x > 0:
    y = x * x
  else:
    y = -x
  return y

converted_f = to_graph(f)
x = tf.constant(2)
converted_f(x)  # converted_foo is like a TensorFlow Op.
<tf.Tensor: shape=(), dtype=int32, numpy=4>
 Supported Python entities include:  functions classes object methods  Functions are converted into new functions with converted code. Classes are converted by generating a new class whose methods use converted code. Methods are converted into unbound function that have an additional first argument called self. For a tutorial, see the tf.function and AutoGraph guide. For more detailed information, see the AutoGraph reference documentation.
 


 Args
  entity   Python callable or class to convert.  
  recursive   Whether to recursively convert any functions that the converted function may call.  
  experimental_optional_features   None, a tuple of, or a single tf.autograph.experimental.Feature value.   
 


 Returns   Same as entity, the converted Python function or class.  

 


 Raises
  ValueError   If the entity could not be converted.
tf.autograph.trace     View source on GitHub    Traces argument information at compilation time.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.autograph.trace  
tf.autograph.trace(
    *args
)
 trace is useful when debugging, and it always executes during the tracing phase, that is, when the TF graph is constructed. Example usage import tensorflow as tf

for i in tf.range(10):
  tf.autograph.trace(i)
# Output: <Tensor ...>

 


 Args
  *args   Arguments to print to sys.stdout.
tf.bitcast Bitcasts a tensor from one type to another without copying data.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.bitcast  
tf.bitcast(
    input, type, name=None
)
 Given a tensor input, this operation returns a tensor that has the same buffer data as input with datatype type. If the input datatype T is larger than the output datatype type then the shape changes from [...] to [..., sizeof(T)/sizeof(type)]. If T is smaller than type, the operator requires that the rightmost dimension be equal to sizeof(type)/sizeof(T). The shape then goes from [..., sizeof(type)/sizeof(T)] to [...]. tf.bitcast() and tf.cast() work differently when real dtype is casted as a complex dtype (e.g. tf.complex64 or tf.complex128) as tf.cast() make imaginary part 0 while tf.bitcast() gives module error. For example, Example 1: 
a = [1., 2., 3.]
equality_bitcast = tf.bitcast(a, tf.complex128)
Traceback (most recent call last):

InvalidArgumentError: Cannot bitcast from 1 to 18 [Op:Bitcast]
equality_cast = tf.cast(a, tf.complex128)
print(equality_cast)
tf.Tensor([1.+0.j 2.+0.j 3.+0.j], shape=(3,), dtype=complex128)
 Example 2: 
tf.bitcast(tf.constant(0xffffffff, dtype=tf.uint32), tf.uint8)
<tf.Tensor: shape=(4,), dtype=uint8, numpy=array([255, 255, 255, 255], dtype=uint8)>
 Example 3: 
x = [1., 2., 3.]
y = [0., 2., 3.]
equality= tf.equal(x,y)
equality_cast = tf.cast(equality,tf.float32)
equality_bitcast = tf.bitcast(equality_cast,tf.uint8)
print(equality)
tf.Tensor([False True True], shape=(3,), dtype=bool)
print(equality_cast)
tf.Tensor([0. 1. 1.], shape=(3,), dtype=float32)
print(equality_bitcast)
tf.Tensor(
    [[  0   0   0   0]
     [  0   0 128  63]
     [  0   0 128  63]], shape=(3, 4), dtype=uint8)
 
Note: Bitcast is implemented as a low-level cast, so machines with different endian orderings will give different results.

 


 Args
  input   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, int64, int32, uint8, uint16, uint32, uint64, int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32.  
  type   A tf.DType from: tf.bfloat16, tf.half, tf.float32, tf.float64, tf.int64, tf.int32, tf.uint8, tf.uint16, tf.uint32, tf.uint64, tf.int8, tf.int16, tf.complex64, tf.complex128, tf.qint8, tf.quint8, tf.qint16, tf.quint16, tf.qint32.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type type.
Module: tf.bitwise Operations for manipulating the binary representations of integers. Functions bitwise_and(...): Elementwise computes the bitwise AND of x and y. bitwise_or(...): Elementwise computes the bitwise OR of x and y. bitwise_xor(...): Elementwise computes the bitwise XOR of x and y. invert(...): Invert (flip) each bit of supported types; for example, type uint8 value 01010101 becomes 10101010. left_shift(...): Elementwise computes the bitwise left-shift of x and y. right_shift(...): Elementwise computes the bitwise right-shift of x and y.
tf.bitwise.bitwise_and Elementwise computes the bitwise AND of x and y.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.bitwise.bitwise_and  
tf.bitwise.bitwise_and(
    x, y, name=None
)
 The result will have those bits set, that are set in both x and y. The computation is performed on the underlying representations of x and y. For example: import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([0, 0, 3, 10], dtype=tf.float32)

  res = bitwise_ops.bitwise_and(lhs, rhs)
  tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE

 


 Args
  x   A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.  
  y   A Tensor. Must have the same type as x.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as x.
tf.bitwise.bitwise_or Elementwise computes the bitwise OR of x and y.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.bitwise.bitwise_or  
tf.bitwise.bitwise_or(
    x, y, name=None
)
 The result will have those bits set, that are set in x, y or both. The computation is performed on the underlying representations of x and y. For example: import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([5, 5, 7, 15], dtype=tf.float32)

  res = bitwise_ops.bitwise_or(lhs, rhs)
  tf.assert_equal(tf.cast(res,  tf.float32), exp)  # TRUE

 


 Args
  x   A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.  
  y   A Tensor. Must have the same type as x.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as x.
tf.bitwise.bitwise_xor Elementwise computes the bitwise XOR of x and y.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.bitwise.bitwise_xor  
tf.bitwise.bitwise_xor(
    x, y, name=None
)
 The result will have those bits set, that are different in x and y. The computation is performed on the underlying representations of x and y. For example: import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([5, 5, 4, 5],  dtype=tf.float32)

  res = bitwise_ops.bitwise_xor(lhs, rhs)
  tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE

 


 Args
  x   A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.  
  y   A Tensor. Must have the same type as x.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as x.
tf.bitwise.invert Invert (flip) each bit of supported types; for example, type uint8 value 01010101 becomes 10101010.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.bitwise.invert  
tf.bitwise.invert(
    x, name=None
)
 Flip each bit of supported types. For example, type int8 (decimal 2) binary 00000010 becomes (decimal -3) binary 11111101. This operation is performed on each element of the tensor argument x. Example: import tensorflow as tf
from tensorflow.python.ops import bitwise_ops

# flip 2 (00000010) to -3 (11111101)
tf.assert_equal(-3, bitwise_ops.invert(2))

dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64,
              dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64]

inputs = [0, 5, 3, 14]
for dtype in dtype_list:
  # Because of issues with negative numbers, let's test this indirectly.
  # 1. invert(a) and a = 0
  # 2. invert(a) or a = invert(0)
  input_tensor = tf.constant([0, 5, 3, 14], dtype=dtype)
  not_a_and_a, not_a_or_a, not_0 = [bitwise_ops.bitwise_and(
                                      input_tensor, bitwise_ops.invert(input_tensor)),
                                    bitwise_ops.bitwise_or(
                                      input_tensor, bitwise_ops.invert(input_tensor)),
                                    bitwise_ops.invert(
                                      tf.constant(0, dtype=dtype))]

  expected = tf.constant([0, 0, 0, 0], dtype=tf.float32)
  tf.assert_equal(tf.cast(not_a_and_a, tf.float32), expected)

  expected = tf.cast([not_0] * 4, tf.float32)
  tf.assert_equal(tf.cast(not_a_or_a, tf.float32), expected)

  # For unsigned dtypes let's also check the result directly.
  if dtype.is_unsigned:
    inverted = bitwise_ops.invert(input_tensor)
    expected = tf.constant([dtype.max - x for x in inputs], dtype=tf.float32)
    tf.assert_equal(tf.cast(inverted, tf.float32), tf.cast(expected, tf.float32))

 


 Args
  x   A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as x.