neulab/docprompting-conala huggingface dataset:
tf.data.Iterator     View source on GitHub    Represents an iterator of a tf.data.Dataset. tf.data.Iterator is the primary mechanism for enumerating elements of a tf.data.Dataset. It supports the Python Iterator protocol, which means it can be iterated over using a for-loop: 
dataset = tf.data.Dataset.range(2)
for element in dataset:
  print(element)
tf.Tensor(0, shape=(), dtype=int64)
tf.Tensor(1, shape=(), dtype=int64)
 or by fetching individual elements explicitly via get_next(): 
dataset = tf.data.Dataset.range(2)
iterator = iter(dataset)
print(iterator.get_next())
tf.Tensor(0, shape=(), dtype=int64)
print(iterator.get_next())
tf.Tensor(1, shape=(), dtype=int64)
 In addition, non-raising iteration is supported via get_next_as_optional(), which returns the next element (if available) wrapped in a tf.experimental.Optional. 
dataset = tf.data.Dataset.from_tensors(42)
iterator = iter(dataset)
optional = iterator.get_next_as_optional()
print(optional.has_value())
tf.Tensor(True, shape=(), dtype=bool)
optional = iterator.get_next_as_optional()
print(optional.has_value())
tf.Tensor(False, shape=(), dtype=bool)

 


 Attributes
  element_spec   The type specification of an element of this iterator. 
dataset = tf.data.Dataset.from_tensors(42)
iterator = iter(dataset)
iterator.element_spec
tf.TensorSpec(shape=(), dtype=tf.int32, name=None)

   Methods get_next View source 
@abc.abstractmethod
get_next()
 Returns a nested structure of tf.Tensors containing the next element. 
dataset = tf.data.Dataset.from_tensors(42)
iterator = iter(dataset)
print(iterator.get_next())
tf.Tensor(42, shape=(), dtype=int32)

 


 Returns   A nested structure of tf.Tensor objects.  

 


 Raises   tf.errors.OutOfRangeError: If the end of the iterator has been reached.  
 get_next_as_optional View source 
@abc.abstractmethod
get_next_as_optional()
 Returns a tf.experimental.Optional which contains the next element. If the iterator has reached the end of the sequence, the returned tf.experimental.Optional will have no value. 
dataset = tf.data.Dataset.from_tensors(42)
iterator = iter(dataset)
optional = iterator.get_next_as_optional()
print(optional.has_value())
tf.Tensor(True, shape=(), dtype=bool)
print(optional.get_value())
tf.Tensor(42, shape=(), dtype=int32)
optional = iterator.get_next_as_optional()
print(optional.has_value())
tf.Tensor(False, shape=(), dtype=bool)

 


 Returns   A tf.experimental.Optional object representing the next element.  
 __iter__ 
__iter__()
tf.data.IteratorSpec Type specification for tf.data.Iterator. Inherits From: TypeSpec 
tf.data.IteratorSpec(
    element_spec
)
 For instance, tf.data.IteratorSpec can be used to define a tf.function that takes tf.data.Iterator as an input argument: 
@tf.function(input_signature=[tf.data.IteratorSpec(
  tf.TensorSpec(shape=(), dtype=tf.int32, name=None))])
def square(iterator):
  x = iterator.get_next()
  return x * x
dataset = tf.data.Dataset.from_tensors(5)
iterator = iter(dataset)
print(square(iterator))
tf.Tensor(25, shape=(), dtype=int32)

 


 Attributes
  element_spec   A nested structure of TypeSpec objects that represents the type specification of the iterator elements.  
  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 
@staticmethod
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.debugging Public API for tf.debugging namespace. Modules experimental module: Public API for tf.debugging.experimental namespace. Functions Assert(...): Asserts that the given condition is true. assert_all_finite(...): Assert that the tensor does not contain any NaN's or Inf's. assert_equal(...): Assert the condition x == y holds element-wise. assert_greater(...): Assert the condition x > y holds element-wise. assert_greater_equal(...): Assert the condition x >= y holds element-wise. assert_integer(...): Assert that x is of integer dtype. assert_less(...): Assert the condition x < y holds element-wise. assert_less_equal(...): Assert the condition x <= y holds element-wise. assert_near(...): Assert the condition x and y are close element-wise. assert_negative(...): Assert the condition x < 0 holds element-wise. assert_non_negative(...): Assert the condition x >= 0 holds element-wise. assert_non_positive(...): Assert the condition x <= 0 holds element-wise. assert_none_equal(...): Assert the condition x != y holds for all elements. assert_positive(...): Assert the condition x > 0 holds element-wise. assert_proper_iterable(...): Static assert that values is a "proper" iterable. assert_rank(...): Assert that x has rank equal to rank. assert_rank_at_least(...): Assert that x has rank of at least rank. assert_rank_in(...): Assert that x has a rank in ranks. assert_same_float_dtype(...): Validate and return float type based on tensors and dtype. assert_scalar(...): Asserts that the given tensor is a scalar. assert_shapes(...): Assert tensor shapes and dimension size relationships between tensors. assert_type(...): Asserts that the given Tensor is of the specified type. check_numerics(...): Checks a tensor for NaN and Inf values. disable_check_numerics(...): Disable the eager/graph unified numerics checking mechanism. enable_check_numerics(...): Enable tensor numerics checking in an eager/graph unified fashion. get_log_device_placement(...): Get if device placements are logged. is_numeric_tensor(...): Returns True if the elements of tensor are numbers. set_log_device_placement(...): Set if device placements should be logged.
tf.debugging.Assert     View source on GitHub    Asserts that the given condition is true.  View aliases  Main aliases 
tf.Assert Compat aliases for migration See Migration guide for more details. tf.compat.v1.Assert, tf.compat.v1.debugging.Assert  
tf.debugging.Assert(
    condition, data, summarize=None, name=None
)
 If condition evaluates to false, print the list of tensors in data. summarize determines how many entries of the tensors to print.
 


 Args
  condition   The condition to evaluate.  
  data   The tensors to print out when condition is false.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional).   
 


 Returns
  assert_op   An Operation that, when executed, raises a tf.errors.InvalidArgumentError if condition is not true.   
 


 Raises
 
Note: The output of this function should be used. If it is not, a warning will be logged or an error may be raised. To mark the output as used, call its .mark_used() method.
 Tf1 Compatibility When in TF V1 mode (that is, outside tf.function) Assert needs a control dependency on the output to ensure the assertion executes: # Ensure maximum element of x is smaller or equal to 1
assert_op = tf.Assert(tf.less_equal(tf.reduce_max(x), 1.), [x])
with tf.control_dependencies([assert_op]):
  ... code using x ...
 Eager Compatibility returns None
tf.debugging.assert_all_finite     View source on GitHub    Assert that the tensor does not contain any NaN's or Inf's. 
tf.debugging.assert_all_finite(
    x, message, name=None
)

 


 Args
  x   Tensor to check.  
  message   Message to log on failure.  
  name   A name for this operation (optional).   
 


 Returns   Same tensor as x.
tf.debugging.assert_equal     View source on GitHub    Assert the condition x == y holds element-wise.  View aliases  Main aliases 
tf.assert_equal  
tf.debugging.assert_equal(
    x, y, message=None, summarize=None, name=None
)
 This Op checks that x[i] == y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If x and y are not equal, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_equal".   
 


 Returns   Op that raises InvalidArgumentError if x == y is False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x == y is False. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_greater     View source on GitHub    Assert the condition x > y holds element-wise.  View aliases  Main aliases 
tf.assert_greater  
tf.debugging.assert_greater(
    x, y, message=None, summarize=None, name=None
)
 This Op checks that x[i] > y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If x is not greater than y element-wise, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_greater".   
 


 Returns   Op that raises InvalidArgumentError if x > y is False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x > y is False. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_greater_equal     View source on GitHub    Assert the condition x >= y holds element-wise. 
tf.debugging.assert_greater_equal(
    x, y, message=None, summarize=None, name=None
)
 This Op checks that x[i] >= y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If x is not greater or equal to y element-wise, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_greater_equal".   
 


 Returns   Op that raises InvalidArgumentError if x >= y is False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x >= y is False. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_integer     View source on GitHub    Assert that x is of integer dtype. 
tf.debugging.assert_integer(
    x, message=None, name=None
)
 If x has a non-integer type, message, as well as the dtype of x are printed, and InvalidArgumentError is raised. This can always be checked statically, so this method returns nothing.
 


 Args
  x   A Tensor.  
  message   A string to prefix to the default message.  
  name   A name for this operation (optional). Defaults to "assert_integer".   
 


 Raises
  TypeError   If x.dtype is not a non-quantized integer type.
tf.debugging.assert_less     View source on GitHub    Assert the condition x < y holds element-wise.  View aliases  Main aliases 
tf.assert_less  
tf.debugging.assert_less(
    x, y, message=None, summarize=None, name=None
)
 This Op checks that x[i] < y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If x is not less than y element-wise, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_less".   
 


 Returns   Op that raises InvalidArgumentError if x < y is False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x < y is False. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_less_equal     View source on GitHub    Assert the condition x <= y holds element-wise. 
tf.debugging.assert_less_equal(
    x, y, message=None, summarize=None, name=None
)
 This Op checks that x[i] <= y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If x is not less or equal than y element-wise, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_less_equal".   
 


 Returns   Op that raises InvalidArgumentError if x <= y is False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x <= y is False. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_near     View source on GitHub    Assert the condition x and y are close element-wise. 
tf.debugging.assert_near(
    x, y, rtol=None, atol=None, message=None, summarize=None, name=None
)
 This Op checks that x[i] - y[i] < atol + rtol * tf.abs(y[i]) holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If any elements of x and y are not close, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised. The default atol and rtol is 10 * eps, where eps is the smallest representable positive number such that 1 + eps != 1. This is about 1.2e-6 in 32bit, 2.22e-15 in 64bit, and 0.00977 in 16bit. See numpy.finfo.
 


 Args
  x   Float or complex Tensor.  
  y   Float or complex Tensor, same dtype as and broadcastable to x.  
  rtol   Tensor. Same dtype as, and broadcastable to, x. The relative tolerance. Default is 10 * eps.  
  atol   Tensor. Same dtype as, and broadcastable to, x. The absolute tolerance. Default is 10 * eps.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_near".   
 


 Returns   Op that raises InvalidArgumentError if x and y are not close enough. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x != y is False for any pair of elements in x and y. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None Numpy Compatibility Similar to numpy.testing.assert_allclose, except tolerance depends on data type. This is due to the fact that TensorFlow is often used with 32bit, 64bit, and even 16bit data.
tf.debugging.assert_negative     View source on GitHub    Assert the condition x < 0 holds element-wise. 
tf.debugging.assert_negative(
    x, message=None, summarize=None, name=None
)
 This Op checks that x[i] < 0 holds for every element of x. If x is empty, this is trivially satisfied. If x is not negative everywhere, message, as well as the first summarize entries of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_negative".   
 


 Returns   Op raising InvalidArgumentError unless x is all negative. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x[i] < 0 is False. The check can be performed immediately during eager execution or if x is statically known.    Eager Compatibility returns None
tf.debugging.assert_none_equal     View source on GitHub    Assert the condition x != y holds for all elements. 
tf.debugging.assert_none_equal(
    x, y, summarize=None, message=None, name=None
)
 This Op checks that x[i] != y[i] holds for every pair of (possibly broadcast) elements of x and y. If both x and y are empty, this is trivially satisfied. If any elements of x and y are equal, message, as well as the first summarize entries of x and y are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  y   Numeric Tensor, same dtype as and broadcastable to x.  
  summarize   Print this many entries of each tensor.  
  message   A string to prefix to the default message.  
  name   A name for this operation (optional). Defaults to "assert_none_equal".   
 


 Returns   Op that raises InvalidArgumentError if x != y is ever False. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x != y is False for any pair of elements in x and y. The check can be performed immediately during eager execution or if x and y are statically known.    Eager Compatibility returns None
tf.debugging.assert_non_negative     View source on GitHub    Assert the condition x >= 0 holds element-wise. 
tf.debugging.assert_non_negative(
    x, message=None, summarize=None, name=None
)
 This Op checks that x[i] >= 0 holds for every element of x. If x is empty, this is trivially satisfied. If x is not >= 0 everywhere, message, as well as the first summarize entries of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_non_negative".   
 


 Returns   Op raising InvalidArgumentError unless x is all non-negative. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x[i] >= 0 is False. The check can be performed immediately during eager execution or if x is statically known.    Eager Compatibility returns None
tf.debugging.assert_non_positive     View source on GitHub    Assert the condition x <= 0 holds element-wise. 
tf.debugging.assert_non_positive(
    x, message=None, summarize=None, name=None
)
 This Op checks that x[i] <= 0 holds for every element of x. If x is empty, this is trivially satisfied. If x is not <= 0 everywhere, message, as well as the first summarize entries of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_non_positive".   
 


 Returns   Op raising InvalidArgumentError unless x is all non-positive. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x[i] <= 0 is False. The check can be performed immediately during eager execution or if x is statically known.    Eager Compatibility returns None
tf.debugging.assert_positive     View source on GitHub    Assert the condition x > 0 holds element-wise. 
tf.debugging.assert_positive(
    x, message=None, summarize=None, name=None
)
 This Op checks that x[i] > 0 holds for every element of x. If x is empty, this is trivially satisfied. If x is not positive everywhere, message, as well as the first summarize entries of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Numeric Tensor.  
  message   A string to prefix to the default message.  
  summarize   Print this many entries of each tensor.  
  name   A name for this operation (optional). Defaults to "assert_positive".   
 


 Returns   Op raising InvalidArgumentError unless x is all positive. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x[i] > 0 is False. The check can be performed immediately during eager execution or if x is statically known.    Eager Compatibility returns None
tf.debugging.assert_proper_iterable     View source on GitHub    Static assert that values is a "proper" iterable.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.assert_proper_iterable, tf.compat.v1.debugging.assert_proper_iterable  
tf.debugging.assert_proper_iterable(
    values
)
 Ops that expect iterables of Tensor can call this to validate input. Useful since Tensor, ndarray, byte/text type are all iterables themselves.
 


 Args
  values   Object to be checked.   
 


 Raises
  TypeError   If values is not iterable or is one of Tensor, SparseTensor, np.array, tf.compat.bytes_or_text_types.
tf.debugging.assert_rank     View source on GitHub    Assert that x has rank equal to rank.  View aliases  Main aliases 
tf.assert_rank  
tf.debugging.assert_rank(
    x, rank, message=None, name=None
)
 This Op checks that the rank of x is equal to rank. If x has a different rank, message, as well as the shape of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Tensor.  
  rank   Scalar integer Tensor.  
  message   A string to prefix to the default message.  
  name   A name for this operation (optional). Defaults to "assert_rank".   
 


 Returns   Op raising InvalidArgumentError unless x has specified rank. If static checks determine x has correct rank, a no_op is returned. This can be used with tf.control_dependencies inside of tf.functions to block followup computation until the check has executed.  

 


 Raises
  InvalidArgumentError   if the check can be performed immediately and x does not have rank rank. The check can be performed immediately during eager execution or if the shape of x is statically known.    Eager Compatibility returns None