neulab/docprompting-conala huggingface dataset:
tf.compat.v1.enable_eager_execution Enables eager execution for the lifetime of this program. 
tf.compat.v1.enable_eager_execution(
    config=None, device_policy=None, execution_mode=None
)
 Eager execution provides an imperative interface to TensorFlow. With eager execution enabled, TensorFlow functions execute operations immediately (as opposed to adding to a graph to be executed later in a tf.compat.v1.Session) and return concrete values (as opposed to symbolic references to a node in a computational graph). For example: tf.compat.v1.enable_eager_execution()

# After eager execution is enabled, operations are executed as they are
# defined and Tensor objects hold concrete values, which can be accessed as
# numpy.ndarray`s through the numpy() method.
assert tf.multiply(6, 7).numpy() == 42
 Eager execution cannot be enabled after TensorFlow APIs have been used to create or execute graphs. It is typically recommended to invoke this function at program startup and not in a library (as most libraries should be usable both with and without eager execution).
 


 Args
  config   (Optional.) A tf.compat.v1.ConfigProto to use to configure the environment in which operations are executed. Note that tf.compat.v1.ConfigProto is also used to configure graph execution (via tf.compat.v1.Session) and many options within tf.compat.v1.ConfigProto are not implemented (or are irrelevant) when eager execution is enabled.  
  device_policy   (Optional.) Policy controlling how operations requiring inputs on a specific device (e.g., a GPU 0) handle inputs on a different device (e.g. GPU 1 or CPU). When set to None, an appropriate value will be picked automatically. The value picked may change between TensorFlow releases. Valid values:  tf.contrib.eager.DEVICE_PLACEMENT_EXPLICIT: raises an error if the placement is not correct. tf.contrib.eager.DEVICE_PLACEMENT_WARN: copies the tensors which are not on the right device but logs a warning. tf.contrib.eager.DEVICE_PLACEMENT_SILENT: silently copies the tensors. Note that this may hide performance problems as there is no notification provided when operations are blocked on the tensor being copied between devices. tf.contrib.eager.DEVICE_PLACEMENT_SILENT_FOR_INT32: silently copies int32 tensors, raising errors on the other ones. 

 
  execution_mode   (Optional.) Policy controlling how operations dispatched are actually executed. When set to None, an appropriate value will be picked automatically. The value picked may change between TensorFlow releases. Valid values: tf.contrib.eager.SYNC: executes each operation synchronously. tf.contrib.eager.ASYNC: executes each operation asynchronously. These operations may return "non-ready" handles. 
  
 


 Raises
  ValueError   If eager execution is enabled after creating/executing a TensorFlow graph, or if options provided conflict with a previous call to this function.
tf.compat.v1.enable_resource_variables Creates resource variables by default. 
tf.compat.v1.enable_resource_variables()
 Resource variables are improved versions of TensorFlow variables with a well-defined memory model. Accessing a resource variable reads its value, and all ops which access a specific read value of the variable are guaranteed to see the same value for that tensor. Writes which happen after a read (by having a control or data dependency on the read) are guaranteed not to affect the value of the read tensor, and similarly writes which happen before a read are guaranteed to affect the value. No guarantees are made about unordered read/write pairs. Calling tf.enable_resource_variables() lets you opt-in to this TensorFlow 2.0 feature.
tf.compat.v1.enable_tensor_equality Compare Tensors with element-wise comparison and thus be unhashable. 
tf.compat.v1.enable_tensor_equality()
 Comparing tensors with element-wise allows comparisons such as tf.Variable(1.0) == 1.0. Element-wise equality implies that tensors are unhashable. Thus tensors can no longer be directly used in sets or as a key in a dictionary.
tf.compat.v1.enable_v2_behavior Enables TensorFlow 2.x behaviors. 
tf.compat.v1.enable_v2_behavior()
 This function can be called at the beginning of the program (before Tensors, Graphs or other structures have been created, and before devices have been initialized. It switches all global behaviors that are different between TensorFlow 1.x and 2.x to behave as intended for 2.x. This function is called in the main TensorFlow __init__.py file, user should not need to call it, except during complex migrations.
tf.compat.v1.enable_v2_tensorshape In TensorFlow 2.0, iterating over a TensorShape instance returns values. 
tf.compat.v1.enable_v2_tensorshape()
 This enables the new behavior. Concretely, tensor_shape[i] returned a Dimension instance in V1, but it V2 it returns either an integer, or None. Examples: #######################
# If you had this in V1:
value = tensor_shape[i].value

# Do this in V2 instead:
value = tensor_shape[i]

#######################
# If you had this in V1:
for dim in tensor_shape:
  value = dim.value
  print(value)

# Do this in V2 instead:
for value in tensor_shape:
  print(value)

#######################
# If you had this in V1:
dim = tensor_shape[i]
dim.assert_is_compatible_with(other_shape)  # or using any other shape method

# Do this in V2 instead:
if tensor_shape.rank is None:
  dim = Dimension(None)
else:
  dim = tensor_shape.dims[i]
dim.assert_is_compatible_with(other_shape)  # or using any other shape method

# The V2 suggestion above is more explicit, which will save you from
# the following trap (present in V1):
# you might do in-place modifications to `dim` and expect them to be reflected
# in `tensor_shape[i]`, but they would not be.
Module: tf.compat.v1.errors Exception types for TensorFlow errors. Classes class AbortedError: The operation was aborted, typically due to a concurrent action. class AlreadyExistsError: Raised when an entity that we attempted to create already exists. class CancelledError: Raised when an operation or step is cancelled. class DataLossError: Raised when unrecoverable data loss or corruption is encountered. class DeadlineExceededError: Raised when a deadline expires before an operation could complete. class FailedPreconditionError: Operation was rejected because the system is not in a state to execute it. class InternalError: Raised when the system experiences an internal error. class InvalidArgumentError: Raised when an operation receives an invalid argument. class NotFoundError: Raised when a requested entity (e.g., a file or directory) was not found. class OpError: A generic error that is raised when TensorFlow execution fails. class OutOfRangeError: Raised when an operation iterates past the valid input range. class PermissionDeniedError: Raised when the caller does not have permission to run an operation. class ResourceExhaustedError: Some resource has been exhausted. class UnauthenticatedError: The request does not have valid authentication credentials. class UnavailableError: Raised when the runtime is currently unavailable. class UnimplementedError: Raised when an operation has not been implemented. class UnknownError: Unknown error. class raise_exception_on_not_ok_status: Context manager to check for C API status. Functions error_code_from_exception_type(...) exception_type_from_error_code(...)
 


 Other Members
  ABORTED   10  
  ALREADY_EXISTS   6  
  CANCELLED   1  
  DATA_LOSS   15  
  DEADLINE_EXCEEDED   4  
  FAILED_PRECONDITION   9  
  INTERNAL   13  
  INVALID_ARGUMENT   3  
  NOT_FOUND   5  
  OK   0  
  OUT_OF_RANGE   11  
  PERMISSION_DENIED   7  
  RESOURCE_EXHAUSTED   8  
  UNAUTHENTICATED   16  
  UNAVAILABLE   14  
  UNIMPLEMENTED   12  
  UNKNOWN   2
tf.compat.v1.errors.error_code_from_exception_type 
tf.compat.v1.errors.error_code_from_exception_type()
tf.compat.v1.errors.exception_type_from_error_code 
tf.compat.v1.errors.exception_type_from_error_code(
    error_code
)
tf.compat.v1.errors.raise_exception_on_not_ok_status Context manager to check for C API status. Methods __enter__ View source 
__enter__()
 __exit__ View source 
__exit__(
    type_arg, value_arg, traceback_arg
)
Module: tf.compat.v1.estimator.experimental Public API for tf.estimator.experimental namespace. Classes class InMemoryEvaluatorHook: Hook to run evaluation in training without a checkpoint. class KMeans: An Estimator for K-Means clustering. class LinearSDCA: Stochastic Dual Coordinate Ascent helper for linear estimators. Functions build_raw_supervised_input_receiver_fn(...): Build a supervised_input_receiver_fn for raw features and labels. call_logit_fn(...): Calls logit_fn (experimental). dnn_logit_fn_builder(...): Function builder for a dnn logit_fn. linear_logit_fn_builder(...): Function builder for a linear logit_fn. make_early_stopping_hook(...): Creates early-stopping hook. make_stop_at_checkpoint_step_hook(...): Creates a proper StopAtCheckpointStepHook based on chief status. stop_if_higher_hook(...): Creates hook to stop if the given metric is higher than the threshold. stop_if_lower_hook(...): Creates hook to stop if the given metric is lower than the threshold. stop_if_no_decrease_hook(...): Creates hook to stop if metric does not decrease within given max steps. stop_if_no_increase_hook(...): Creates hook to stop if metric does not increase within given max steps.
tf.compat.v1.estimator.experimental.dnn_logit_fn_builder Function builder for a dnn logit_fn. 
tf.compat.v1.estimator.experimental.dnn_logit_fn_builder(
    units, hidden_units, feature_columns, activation_fn, dropout,
    input_layer_partitioner, batch_norm
)

 


 Args
  units   An int indicating the dimension of the logit layer. In the MultiHead case, this should be the sum of all component Heads' logit dimensions.  
  hidden_units   Iterable of integer number of hidden units per layer.  
  feature_columns   Iterable of feature_column._FeatureColumn model inputs.  
  activation_fn   Activation function applied to each layer.  
  dropout   When not None, the probability we will drop out a given coordinate.  
  input_layer_partitioner   Partitioner for input layer.  
  batch_norm   Whether to use batch normalization after each hidden layer.   
 


 Returns   A logit_fn (see below).  

 


 Raises
  ValueError   If units is not an int.
tf.compat.v1.estimator.experimental.linear_logit_fn_builder Function builder for a linear logit_fn. 
tf.compat.v1.estimator.experimental.linear_logit_fn_builder(
    units, feature_columns, sparse_combiner='sum'
)

 


 Args
  units   An int indicating the dimension of the logit layer.  
  feature_columns   An iterable containing all the feature columns used by the model.  
  sparse_combiner   A string specifying how to reduce if a categorical column is multivalent. One of "mean", "sqrtn", and "sum".   
 


 Returns   A logit_fn (see below).
Module: tf.compat.v1.estimator.export All public utility methods for exporting Estimator to SavedModel. This file includes functions and constants from core (model_utils) and export.py Classes class ClassificationOutput: Represents the output of a classification head. class ExportOutput: Represents an output of a model that can be served. class PredictOutput: Represents the output of a generic prediction head. class RegressionOutput: Represents the output of a regression head. class ServingInputReceiver: A return type for a serving_input_receiver_fn. class TensorServingInputReceiver: A return type for a serving_input_receiver_fn. Functions build_parsing_serving_input_receiver_fn(...): Build a serving_input_receiver_fn expecting fed tf.Examples. build_raw_serving_input_receiver_fn(...): Build a serving_input_receiver_fn expecting feature Tensors.
Module: tf.compat.v1.estimator.inputs Utility methods to create simple input_fns. Functions numpy_input_fn(...): Returns input function that would feed dict of numpy arrays into the model. pandas_input_fn(...): Returns input function that would feed Pandas DataFrame into the model.
tf.compat.v1.estimator.inputs.numpy_input_fn Returns input function that would feed dict of numpy arrays into the model. 
tf.compat.v1.estimator.inputs.numpy_input_fn(
    x, y=None, batch_size=128, num_epochs=1, shuffle=None, queue_capacity=1000,
    num_threads=1
)
 This returns a function outputting features and targets based on the dict of numpy arrays. The dict features has the same keys as the x. The dict targets has the same keys as the y if y is a dict. Example: age = np.arange(4) * 1.0
height = np.arange(32, 36)
x = {'age': age, 'height': height}
y = np.arange(-32, -28)

with tf.Session() as session:
  input_fn = numpy_io.numpy_input_fn(
      x, y, batch_size=2, shuffle=False, num_epochs=1)

 


 Args
  x   numpy array object or dict of numpy array objects. If an array, the array will be treated as a single feature.  
  y   numpy array object or dict of numpy array object. None if absent.  
  batch_size   Integer, size of batches to return.  
  num_epochs   Integer, number of epochs to iterate over data. If None will run forever.  
  shuffle   Boolean, if True shuffles the queue. Avoid shuffle at prediction time.  
  queue_capacity   Integer, size of queue to accumulate.  
  num_threads   Integer, number of threads used for reading and enqueueing. In order to have predicted and repeatable order of reading and enqueueing, such as in prediction and evaluation mode, num_threads should be 1.   
 


 Returns   Function, that has signature of ()->(dict of features, targets)  

 


 Raises
  ValueError   if the shape of y mismatches the shape of values in x (i.e., values in x have same shape).  
  ValueError   if duplicate keys are in both x and y when y is a dict.  
  ValueError   if x or y is an empty dict.  
  TypeError   x is not a dict or array.  
  ValueError   if 'shuffle' is not provided or a bool.
tf.compat.v1.estimator.inputs.pandas_input_fn Returns input function that would feed Pandas DataFrame into the model. 
tf.compat.v1.estimator.inputs.pandas_input_fn(
    x, y=None, batch_size=128, num_epochs=1, shuffle=None, queue_capacity=1000,
    num_threads=1, target_column='target'
)
 
Note: y's index must match x's index.

 


 Args
  x   pandas DataFrame object.  
  y   pandas Series object or DataFrame. None if absent.  
  batch_size   int, size of batches to return.  
  num_epochs   int, number of epochs to iterate over data. If not None, read attempts that would exceed this value will raise OutOfRangeError.  
  shuffle   bool, whether to read the records in random order.  
  queue_capacity   int, size of the read queue. If None, it will be set roughly to the size of x.  
  num_threads   Integer, number of threads used for reading and enqueueing. In order to have predicted and repeatable order of reading and enqueueing, such as in prediction and evaluation mode, num_threads should be 1.  
  target_column   str, name to give the target column y. This parameter is not used when y is a DataFrame.   
 


 Returns   Function, that has signature of ()->(dict of features, target)  

 


 Raises
  ValueError   if x already contains a column with the same name as y, or if the indexes of x and y don't match.  
  ValueError   if 'shuffle' is not provided or a bool.
Module: tf.compat.v1.estimator.tpu Public API for tf.estimator.tpu namespace. Modules experimental module: Public API for tf.estimator.tpu.experimental namespace. Classes class InputPipelineConfig: Please see the definition of these values in TPUConfig. class RunConfig: RunConfig with TPU support. class TPUConfig: TPU related configuration required by TPUEstimator. class TPUEstimator: Estimator with TPU support. class TPUEstimatorSpec: Ops and objects returned from a model_fn and passed to TPUEstimator.
Module: tf.compat.v1.estimator.tpu.experimental Public API for tf.estimator.tpu.experimental namespace. Classes class EmbeddingConfigSpec: Class to keep track of the specification for TPU embeddings.
tf.compat.v1.estimator.tpu.InputPipelineConfig Please see the definition of these values in TPUConfig.
 


 Class Variables
  BROADCAST   4  
  PER_HOST_V1   2  
  PER_HOST_V2   3  
  PER_SHARD_V1   1  
  SLICED   5
tf.compat.v1.estimator.tpu.TPUEstimatorSpec Ops and objects returned from a model_fn and passed to TPUEstimator. 
tf.compat.v1.estimator.tpu.TPUEstimatorSpec(
    mode, predictions=None, loss=None, train_op=None, eval_metrics=None,
    export_outputs=None, scaffold_fn=None, host_call=None, training_hooks=None,
    evaluation_hooks=None, prediction_hooks=None
)
 See EstimatorSpec for mode, predictions, loss, train_op, and export_outputs. For evaluation, eval_metricsis a tuple of metric_fn and tensors, where metric_fn runs on CPU to generate metrics and tensors represents the Tensors transferred from TPU system to CPU host and passed to metric_fn. To be precise, TPU evaluation expects a slightly different signature from the tf.estimator.Estimator. While EstimatorSpec.eval_metric_ops expects a dict, TPUEstimatorSpec.eval_metrics is a tuple of metric_fn and tensors. The tensors could be a list of Tensors or dict of names to Tensors. The tensors usually specify the model logits, which are transferred back from TPU system to CPU host. All tensors must have be batch-major, i.e., the batch size is the first dimension. Once all tensors are available at CPU host from all shards, they are concatenated (on CPU) and passed as positional arguments to the metric_fn if tensors is list or keyword arguments if tensors is a dict. metric_fn takes the tensors and returns a dict from metric string name to the result of calling a metric function, namely a (metric_tensor, update_op) tuple. See TPUEstimator for MNIST example how to specify the eval_metrics. scaffold_fn is a function running on CPU to generate the Scaffold. This function should not capture any Tensors in model_fn. host_call is a tuple of a function and a list or dictionary of tensors to pass to that function and returns a list of Tensors. host_call currently works for train() and evaluate(). The Tensors returned by the function is executed on the CPU on every step, so there is communication overhead when sending tensors from TPU to CPU. To reduce the overhead, try reducing the size of the tensors. The tensors are concatenated along their major (batch) dimension, and so must be >= rank 1. The host_call is useful for writing summaries with tf.contrib.summary.create_file_writer.
 


 Attributes
  mode  
 
  predictions  
 
  loss  
 
  train_op  
 
  eval_metrics  
 
  export_outputs  
 
  scaffold_fn  
 
  host_call  
 
  training_hooks  
 
  evaluation_hooks  
 
  prediction_hooks  
   Methods as_estimator_spec View source 
as_estimator_spec()
 Creates an equivalent EstimatorSpec used by CPU train/eval.
tf.compat.v1.Event A ProtocolMessage  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.summary.Event 
 


 Attributes
  file_version   string file_version  
  graph_def   bytes graph_def  
  log_message   LogMessage log_message  
  meta_graph_def   bytes meta_graph_def  
  session_log   SessionLog session_log  
  step   int64 step  
  summary   Summary summary  
  tagged_run_metadata   TaggedRunMetadata tagged_run_metadata  
  wall_time   double wall_time
tf.compat.v1.executing_eagerly Checks whether the current thread has eager execution enabled. 
tf.compat.v1.executing_eagerly()
 Eager execution is typically enabled via tf.compat.v1.enable_eager_execution, but may also be enabled within the context of a Python function via tf.contrib.eager.py_func. When eager execution is enabled, returns True in most cases. However, this API might return False in the following use cases.  Executing inside tf.function, unless under tf.init_scope or tf.config.run_functions_eagerly(True) is previously called. Executing inside a transformation function for tf.dataset. 
tf.compat.v1.disable_eager_execution() is called.  
tf.compat.v1.enable_eager_execution()
 General case: 
print(tf.executing_eagerly())
True
 Inside tf.function: 
@tf.function
def fn():
  with tf.init_scope():
    print(tf.executing_eagerly())
  print(tf.executing_eagerly())
fn()
True
False
 Inside tf.function after tf.config.run_functions_eagerly(True) is called: 
tf.config.run_functions_eagerly(True)
@tf.function
def fn():
  with tf.init_scope():
    print(tf.executing_eagerly())
  print(tf.executing_eagerly())
fn()
True
True
tf.config.run_functions_eagerly(False)
 Inside a transformation function for tf.dataset: 
def data_fn(x):
  print(tf.executing_eagerly())
  return x
dataset = tf.data.Dataset.range(100)
dataset = dataset.map(data_fn)
False

 


 Returns   True if the current thread has eager execution enabled.
tf.compat.v1.executing_eagerly_outside_functions Returns True if executing eagerly, even if inside a graph function. 
tf.compat.v1.executing_eagerly_outside_functions()
 This function will check the outermost context for the program and see if it is in eager mode. It is useful comparing to tf.executing_eagerly(), which checks the current context and will return False within a tf.function body. It can be used to build library that behave differently in eager runtime and v1 session runtime (deprecated). Example: 
tf.compat.v1.enable_eager_execution()
@tf.function
def func():
  # A function constructs TensorFlow graphs, it does not execute eagerly,
  # but the outer most context is still eager.
  assert not tf.executing_eagerly()
  return tf.compat.v1.executing_eagerly_outside_functions()
func()
<tf.Tensor: shape=(), dtype=bool, numpy=True>

 


 Returns   boolean, whether the outermost context is in eager mode.
tf.compat.v1.expand_dims Returns a tensor with a length 1 axis inserted at index axis. (deprecated arguments) 
tf.compat.v1.expand_dims(
    input, axis=None, name=None, dim=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (dim). They will be removed in a future version. Instructions for updating: Use the axis argument instead Given a tensor input, this operation inserts a dimension of length 1 at the dimension index axis of input's shape. The dimension index follows Python indexing rules: It's zero-based, a negative index it is counted backward from the end. This operation is useful to:  Add an outer "batch" dimension to a single element. Align axes for broadcasting. To add an inner vector length axis to a tensor of scalars.  For example: If you have a single image of shape [height, width, channels]: 
image = tf.zeros([10,10,3])
 You can add an outer batch axis by passing axis=0: 
tf.expand_dims(image, axis=0).shape.as_list()
[1, 10, 10, 3]
 The new axis location matches Python list.insert(axis, 1): 
tf.expand_dims(image, axis=1).shape.as_list()
[10, 1, 10, 3]
 Following standard Python indexing rules, a negative axis counts from the end so axis=-1 adds an inner most dimension: 
tf.expand_dims(image, -1).shape.as_list()
[10, 10, 3, 1]
 This operation requires that axis is a valid index for input.shape, following Python indexing rules: -1-tf.rank(input) <= axis <= tf.rank(input)
 This operation is related to:  
tf.squeeze, which removes dimensions of size 1. 
tf.reshape, which provides more flexible reshaping capability. 
tf.sparse.expand_dims, which provides this functionality for tf.SparseTensor
 
 


 Args
  input   A Tensor.  
  axis   0-D (scalar). Specifies the dimension index at which to expand the shape of input. Must be in the range [-rank(input) - 1, rank(input)].  
  name   The name of the output Tensor (optional).  
  dim   0-D (scalar). Equivalent to axis, to be deprecated.   
 


 Returns   A Tensor with the same data as input, but its shape has an additional dimension of size 1 added.  

 


 Raises
  ValueError   if either both or neither of dim and axis are specified.
Module: tf.compat.v1.experimental Public API for tf.experimental namespace. Classes class Optional: Represents a value that may or may not be present. Functions async_clear_error(...): Clear pending operations and error statuses in async execution. async_scope(...): Context manager for grouping async operations. function_executor_type(...): Context manager for setting the executor of eager defined functions. output_all_intermediates(...): Whether to output all intermediates from functional control flow ops. register_filesystem_plugin(...): Loads a TensorFlow FileSystem plugin.