neulab/docprompting-conala huggingface dataset:
tf.debugging.assert_rank_at_least     View source on GitHub    Assert that x has rank of at least rank. 
tf.debugging.assert_rank_at_least(
    x, rank, message=None, name=None
)
 This Op checks that the rank of x is greater or equal to rank. If x has a rank lower than 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_at_least".   
 


 Returns   Op raising InvalidArgumentError unless x has specified rank or higher. 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   x does not have rank at least rank, but the rank cannot be statically determined.  
  ValueError   If static checks determine x has mismatched rank.    Eager Compatibility returns None
tf.debugging.assert_rank_in     View source on GitHub    Assert that x has a rank in ranks. 
tf.debugging.assert_rank_in(
    x, ranks, message=None, name=None
)
 This Op checks that the rank of x is in ranks. If x has a different rank, message, as well as the shape of x are printed, and InvalidArgumentError is raised.
 


 Args
  x   Tensor.  
  ranks   Iterable of scalar Tensor objects.  
  message   A string to prefix to the default message.  
  name   A name for this operation (optional). Defaults to "assert_rank_in".   
 


 Returns   Op raising InvalidArgumentError unless rank of x is in ranks. If static checks determine x has matching 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   x does not have rank in ranks, but the rank cannot be statically determined.  
  ValueError   If static checks determine x has mismatched rank.    Eager Compatibility returns None
tf.debugging.assert_same_float_dtype     View source on GitHub    Validate and return float type based on tensors and dtype.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.assert_same_float_dtype, tf.compat.v1.debugging.assert_same_float_dtype  
tf.debugging.assert_same_float_dtype(
    tensors=None, dtype=None
)
 For ops such as matrix multiplication, inputs and weights must be of the same float type. This function validates that all tensors are the same type, validates that type is dtype (if supplied), and returns the type. Type must be a floating point type. If neither tensors nor dtype is supplied, the function will return dtypes.float32.
 


 Args
  tensors   Tensors of input values. Can include None elements, which will be ignored.  
  dtype   Expected type.   
 


 Returns   Validated type.  

 


 Raises
  ValueError   if neither tensors nor dtype is supplied, or result is not float, or the common type of the inputs is not a floating point type.
tf.debugging.assert_scalar     View source on GitHub    Asserts that the given tensor is a scalar. 
tf.debugging.assert_scalar(
    tensor, message=None, name=None
)
 This function raises ValueError unless it can be certain that the given tensor is a scalar. ValueError is also raised if the shape of tensor is unknown. This is always checked statically, so this method returns nothing.
 


 Args
  tensor   A Tensor.  
  message   A string to prefix to the default message.  
  name   A name for this operation. Defaults to "assert_scalar"   
 


 Raises
  ValueError   If the tensor is not scalar (rank 0), or if its shape is unknown.
tf.debugging.assert_shapes     View source on GitHub    Assert tensor shapes and dimension size relationships between tensors. 
tf.debugging.assert_shapes(
    shapes, data=None, summarize=None, message=None, name=None
)
 This Op checks that a collection of tensors shape relationships satisfies given constraints. Example: 
n = 10
q = 3
d = 7
x = tf.zeros([n,q])
y = tf.ones([n,d])
param = tf.Variable([1.0, 2.0, 3.0])
scalar = 1.0
tf.debugging.assert_shapes([
 (x, ('N', 'Q')),
 (y, ('N', 'D')),
 (param, ('Q',)),
 (scalar, ()),
])
 
tf.debugging.assert_shapes([
  (x, ('N', 'D')),
  (y, ('N', 'D'))
])
Traceback (most recent call last):

ValueError: ...
 If x, y, param or scalar does not have a shape that satisfies all specified constraints, message, as well as the first summarize entries of the first encountered violating tensor are printed, and InvalidArgumentError is raised. Size entries in the specified shapes are checked against other entries by their hash, except:  a size entry is interpreted as an explicit size if it can be parsed as an integer primitive. a size entry is interpreted as any size if it is None or '.'.  If the first entry of a shape is ... (type Ellipsis) or '*' that indicates a variable number of outer dimensions of unspecified size, i.e. the constraint applies to the inner-most dimensions only. Scalar tensors and specified shapes of length zero (excluding the 'inner-most' prefix) are both treated as having a single dimension of size one.
 


 Args
  shapes   dictionary with (Tensor to shape) items, or a list of (Tensor, shape) tuples. A shape must be an iterable.  
  data   The tensors to print out if the condition is False. Defaults to error message and first few entries of the violating tensor.  
  summarize   Print this many entries of the tensor.  
  message   A string to prefix to the default message.  
  name   A name for this operation (optional). Defaults to "assert_shapes".   
 


 Raises
  ValueError   If static checks determine any shape constraint is violated.
tf.debugging.assert_type     View source on GitHub    Asserts that the given Tensor is of the specified type. 
tf.debugging.assert_type(
    tensor, tf_type, message=None, name=None
)
 This can always be checked statically, so this method returns nothing.
 


 Args
  tensor   A Tensor or SparseTensor.  
  tf_type   A tensorflow type (dtypes.float32, tf.int64, dtypes.bool, etc).  
  message   A string to prefix to the default message.  
  name   A name for this operation. Defaults to "assert_type"   
 


 Raises
  TypeError   If the tensor's data type doesn't match tf_type.
tf.debugging.check_numerics Checks a tensor for NaN and Inf values.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.check_numerics, tf.compat.v1.debugging.check_numerics  
tf.debugging.check_numerics(
    tensor, message, name=None
)
 When run, reports an InvalidArgument error if tensor has any values that are not a number (NaN) or infinity (Inf). Otherwise, passes tensor as-is.
 


 Args
  tensor   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.  
  message   A string. Prefix of the error message.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as tensor.
tf.debugging.disable_check_numerics Disable the eager/graph unified numerics checking mechanism.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.debugging.disable_check_numerics  
tf.debugging.disable_check_numerics()
 This method can be used after a call to tf.debugging.enable_check_numerics() to disable the numerics-checking mechanism that catches infinity and NaN values output by ops executed eagerly or in tf.function-compiled graphs. This method is idempotent. Calling it multiple times has the same effect as calling it once. This method takes effect only on the thread in which it is called.
Module: tf.debugging.experimental Public API for tf.debugging.experimental namespace. Functions disable_dump_debug_info(...): Disable the currently-enabled debugging dumping. enable_dump_debug_info(...): Enable dumping debugging information from a TensorFlow program.
tf.debugging.experimental.disable_dump_debug_info Disable the currently-enabled debugging dumping.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.debugging.experimental.disable_dump_debug_info  
tf.debugging.experimental.disable_dump_debug_info()
 If the enable_dump_debug_info() method under the same Python namespace has been invoked before, calling this method disables it. If no call to enable_dump_debug_info() has been made, calling this method is a no-op. Calling this method more than once is idempotent.
tf.debugging.get_log_device_placement     View source on GitHub    Get if device placements are logged.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.debugging.get_log_device_placement  
tf.debugging.get_log_device_placement()

 


 Returns   If device placements are logged.
tf.debugging.is_numeric_tensor     View source on GitHub    Returns True if the elements of tensor are numbers.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.debugging.is_numeric_tensor, tf.compat.v1.is_numeric_tensor  
tf.debugging.is_numeric_tensor(
    tensor
)
 Specifically, returns True if the dtype of tensor is one of the following:  tf.float32 tf.float64 tf.int8 tf.int16 tf.int32 tf.int64 tf.uint8 tf.qint8 tf.qint32 tf.quint8 tf.complex64  Returns False if tensor is of a non-numeric type or if tensor is not a tf.Tensor object.
tf.debugging.set_log_device_placement     View source on GitHub    Set if device placements should be logged.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.debugging.set_log_device_placement  
tf.debugging.set_log_device_placement(
    enabled
)

 


 Args
  enabled   Whether to enabled device placement logging.
tf.device     View source on GitHub    Specifies the device for ops created/executed in this context. 
tf.device(
    device_name
)
 This function specifies the device to be used for ops created/executed in a particular context. Nested contexts will inherit and also create/execute their ops on the specified device. If a specific device is not required, consider not using this function so that a device can be automatically assigned. In general the use of this function is optional. device_name can be fully specified, as in "/job:worker/task:1/device:cpu:0", or partially specified, containing only a subset of the "/"-separated fields. Any fields which are specified will override device annotations from outer scopes. For example: with tf.device('/job:foo'):
  # ops created here have devices with /job:foo
  with tf.device('/job:bar/task:0/device:gpu:2'):
    # ops created here have the fully specified device above
  with tf.device('/device:gpu:1'):
    # ops created here have the device '/job:foo/device:gpu:1'

 


 Args
  device_name   The device name to use in the context.   
 


 Returns   A context manager that specifies the default device to use for newly created ops.  

 


 Raises
  RuntimeError   If a function is passed in.
Module: tf.distribute.cluster_resolver Library imports for ClusterResolvers. This library contains all implementations of ClusterResolvers. ClusterResolvers are a way of specifying cluster information for distributed execution. Built on top of existing ClusterSpec framework, ClusterResolvers are a way for TensorFlow to communicate with various cluster management systems (e.g. GCE, AWS, etc...). Classes class ClusterResolver: Abstract class for all implementations of ClusterResolvers. class GCEClusterResolver: ClusterResolver for Google Compute Engine. class KubernetesClusterResolver: ClusterResolver for Kubernetes. class SimpleClusterResolver: Simple implementation of ClusterResolver that accepts all attributes. class SlurmClusterResolver: ClusterResolver for system with Slurm workload manager. class TFConfigClusterResolver: Implementation of a ClusterResolver which reads the TF_CONFIG EnvVar. class TPUClusterResolver: Cluster Resolver for Google Cloud TPUs. class UnionResolver: Performs a union on underlying ClusterResolvers.
tf.distribute.DistributedValues Base class for representing distributed values. 
tf.distribute.DistributedValues(
    values
)
 A subclass instance of tf.distribute.DistributedValues is created when creating variables within a distribution strategy, iterating a tf.distribute.DistributedDataset or through tf.distribute.Strategy.run. This base class should never be instantiated directly. tf.distribute.DistributedValues contains a value per replica. Depending on the subclass, the values could either be synced on update, synced on demand, or never synced. tf.distribute.DistributedValues can be reduced to obtain single value across replicas, as input into tf.distribute.Strategy.run or the per-replica values inspected using tf.distribute.Strategy.experimental_local_results. Example usage:  Created from a tf.distribute.DistributedDataset:  
strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2)
dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset))
distributed_values = next(dataset_iterator)
  Returned by run:  
strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
@tf.function
def run():
  ctx = tf.distribute.get_replica_context()
  return ctx.replica_id_in_sync_group
distributed_values = strategy.run(run)
  As input into run:  
strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2)
dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset))
distributed_values = next(dataset_iterator)
@tf.function
def run(input):
  return input + 1.0
updated_value = strategy.run(run, args=(distributed_values,))
  Reduce value:  
strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2)
dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset))
distributed_values = next(dataset_iterator)
reduced_value = strategy.reduce(tf.distribute.ReduceOp.SUM,
                                distributed_values,
                                axis = 0)
  Inspect local replica values:  
strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2)
dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset))
per_replica_values = strategy.experimental_local_results(
   distributed_values)
per_replica_values
(<tf.Tensor: shape=(1,), dtype=float32, numpy=array([5.], dtype=float32)>,
 <tf.Tensor: shape=(1,), dtype=float32, numpy=array([6.], dtype=float32)>)
Module: tf.distribute.experimental Public API for tf.distribute.experimental namespace. Modules coordinator module: Public API for tf.distribute.experimental.coordinator namespace. partitioners module: Public API for tf.distribute.experimental.partitioners namespace. Classes class CentralStorageStrategy: A one-machine strategy that puts all variables on a single device. class CollectiveCommunication: Cross device communication implementation. class CollectiveHints: Hints for collective operations like AllReduce. class CommunicationImplementation: Cross device communication implementation. class CommunicationOptions: Options for cross device communications like All-reduce. class MultiWorkerMirroredStrategy: A distribution strategy for synchronous training on multiple workers. class ParameterServerStrategy: An multi-worker tf.distribute strategy with parameter servers. class TPUStrategy: Synchronous training on TPUs and TPU Pods. class ValueContext: A class wrapping information needed by a distribute function.
tf.distribute.experimental.CollectiveHints Hints for collective operations like AllReduce.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.distribute.experimental.CollectiveHints  
tf.distribute.experimental.CollectiveHints(
    bytes_per_pack=0, timeout_seconds=None
)
 This can be passed to methods like tf.distribute.get_replica_context().all_reduce() to optimize collective operation performance. Note that these are only hints, which may or may not change the actual behavior. Some options only apply to certain strategy and are ignored by others. One common optimization is to break gradients all-reduce into multiple packs so that weight updates can overlap with gradient all-reduce. Examples:  bytes_per_pack  hints = tf.distribute.experimental.CollectiveHints(
    bytes_per_pack=50 * 1024 * 1024)
grads = tf.distribute.get_replica_context().all_reduce(
    'sum', grads, experimental_hints=hints)
optimizer.apply_gradients(zip(grads, vars),
    experimental_aggregate_gradients=False)
  timeout_seconds  strategy = tf.distribute.MirroredStrategy()
hints = tf.distribute.experimental.CollectiveHints(
    timeout_seconds=120)
try:
  strategy.reduce("sum", v, axis=None, experimental_hints=hints)
except tf.errors.DeadlineExceededError:
  do_something()

 


 Args
  bytes_per_pack   a non-negative integer. Breaks collective operations into packs of certain size. If it's zero, the value is determined automatically. This only applies to all-reduce with MultiWorkerMirroredStrategy currently.  
  timeout_seconds   a float or None, timeout in seconds. If not None, the collective raises tf.errors.DeadlineExceededError if it takes longer than this timeout. This can be useful when debugging hanging issues. This should only be used for debugging since it creates a new thread for each collective, i.e. an overhead of timeout_seconds * num_collectives_per_second more threads. This only works for tf.distribute.experimental.MultiWorkerMirroredStrategy.   
 


 Raises
  ValueError   When arguments have invalid value.
tf.distribute.experimental.CommunicationImplementation Cross device communication implementation.  View aliases  Main aliases 
tf.distribute.experimental.CollectiveCommunication Compat aliases for migration See Migration guide for more details. tf.compat.v1.distribute.experimental.CollectiveCommunication, tf.compat.v1.distribute.experimental.CommunicationImplementation  Warning: The alias tf.distribute.experimental.CollectiveCommunication is deprecated and will be removed in a future version. Use tf.distribute.experimental.CommunicationImplementation instead.  
AUTO: Automatically chosen by Tensorflow. 
RING: TensorFlow's ring algorithms for all-reduce and all-gather. 
NCCL: NVIDIA®'s NCCL library. This is now only used for all-reduce on GPUs; all-reduce on CPU, all-gather and broadcast fallbacks to RING. 
 


 Class Variables
  AUTO   tf.distribute.experimental.CommunicationImplementation  
  NCCL   tf.distribute.experimental.CommunicationImplementation  
  RING   tf.distribute.experimental.CommunicationImplementation
tf.distribute.experimental.CommunicationOptions Options for cross device communications like All-reduce.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.distribute.experimental.CommunicationOptions  
tf.distribute.experimental.CommunicationOptions(
    bytes_per_pack=0, timeout_seconds=None,
    implementation=tf.distribute.experimental.CollectiveCommunication.AUTO
)
 This can be passed to methods like tf.distribute.get_replica_context().all_reduce() to optimize collective operation performance. Note that these are only hints, which may or may not change the actual behavior. Some options only apply to certain strategy and are ignored by others. One common optimization is to break gradients all-reduce into multiple packs so that weight updates can overlap with gradient all-reduce. Examples: options = tf.distribute.experimental.CommunicationOptions(
    bytes_per_pack=50 * 1024 * 1024,
    timeout_seconds=120,
    implementation=tf.distribute.experimental.CommunicationImplementation.NCCL
)
grads = tf.distribute.get_replica_context().all_reduce(
    'sum', grads, options=options)
optimizer.apply_gradients(zip(grads, vars),
    experimental_aggregate_gradients=False)

 


 Args
  bytes_per_pack   a non-negative integer. Breaks collective operations into packs of certain size. If it's zero, the value is determined automatically. This only applies to all-reduce with MultiWorkerMirroredStrategy currently.  
  timeout_seconds   a float or None, timeout in seconds. If not None, the collective raises tf.errors.DeadlineExceededError if it takes longer than this timeout. Zero disables timeout. This can be useful when debugging hanging issues. This should only be used for debugging since it creates a new thread for each collective, i.e. an overhead of timeout_seconds * num_collectives_per_second more threads. This only works for tf.distribute.experimental.MultiWorkerMirroredStrategy.  
  implementation   a tf.distribute.experimental.CommunicationImplementation. This is a hint on the preferred communication implementation. Possible values include AUTO, RING, and NCCL. NCCL is generally more performant for GPU, but doesn't work for CPU. This only works for tf.distribute.experimental.MultiWorkerMirroredStrategy.   
 


 Raises
  ValueError   When arguments have invalid value.
Module: tf.distribute.experimental.coordinator Public API for tf.distribute.experimental.coordinator namespace. Classes class ClusterCoordinator: An object to schedule and coordinate remote function execution. class PerWorkerValues: A container that holds a list of values, one value per worker. class RemoteValue: An asynchronously available value of a scheduled function.
tf.distribute.experimental.coordinator.PerWorkerValues A container that holds a list of values, one value per worker. 
tf.distribute.experimental.coordinator.PerWorkerValues(
    values
)
 tf.distribute.experimental.coordinator.PerWorkerValues contains a collection of values, where each of the value is located one worker respectively, and upon being used as one of the args or kwargs of tf.distribute.experimental.coordinator.ClusterCoordinator.schedule(), the value specific to a worker will be passed into the function being executed at that particular worker. Currently, the only supported path to create an object of tf.distribute.experimental.coordinator.PerWorkerValues is through calling iter on a ClusterCoordinator.create_per_worker_dataset-returned distributed dataset instance. The mechanism to create a custom tf.distribute.experimental.coordinator.PerWorkerValues is not yet supported.
tf.distribute.experimental.coordinator.RemoteValue An asynchronously available value of a scheduled function. This class is used as the return value of tf.distribute.experimental.coordinator.ClusterCoordinator.schedule where the underlying value becomes available at a later time once the function has been executed. Using tf.distribute.experimental.coordinator.RemoteValue as an input to a subsequent function scheduled with tf.distribute.experimental.coordinator.ClusterCoordinator.schedule is currently not supported. Example: strategy = tf.distribute.experimental.ParameterServerStrategy(
    cluster_resolver=...)
coordinator = (
    tf.distribute.experimental.coordinator.ClusterCoordinator(strategy))

with strategy.scope():
  v1 = tf.Variable(initial_value=0.0)
  v2 = tf.Variable(initial_value=1.0)

@tf.function
def worker_fn():
  v1.assign_add(0.1)
  v2.assign_sub(0.2)
  return v1.read_value() / v2.read_value()

result = coordinator.schedule(worker_fn)
# Note that `fetch()` gives the actual result instead of a `tf.Tensor`.
assert result.fetch() == 0.125

for _ in range(10):
  # `worker_fn` will be run on arbitrary workers that are available. The
  # `result` value will be available later.
  result = coordinator.schedule(worker_fn)
 Methods fetch View source 
fetch()
 Wait for the result of RemoteValue to be ready and return the result. This makes the value concrete by copying the remote value to local.
 


 Returns   The actual output of the tf.function associated with this RemoteValue, previously by a tf.distribute.experimental.coordinator.ClusterCoordinator.schedule call. This can be a single value, or a structure of values, depending on the output of the tf.function.  

 


 Raises
  tf.errors.CancelledError   If the function that produces this RemoteValue is aborted or cancelled due to failure.