neulab/docprompting-conala huggingface dataset:
tf.transpose     View source on GitHub    Transposes a, where a is a Tensor. 
tf.transpose(
    a, perm=None, conjugate=False, name='transpose'
)
 Permutes the dimensions according to the value of perm. The returned tensor's dimension i will correspond to the input dimension perm[i]. If perm is not given, it is set to (n-1...0), where n is the rank of the input tensor. Hence by default, this operation performs a regular matrix transpose on 2-D input Tensors. If conjugate is True and a.dtype is either complex64 or complex128 then the values of a are conjugated and transposed. For example: 
x = tf.constant([[1, 2, 3], [4, 5, 6]])
tf.transpose(x)
<tf.Tensor: shape=(3, 2), dtype=int32, numpy=
array([[1, 4],
       [2, 5],
       [3, 6]], dtype=int32)>
 Equivalently, you could call tf.transpose(x, perm=[1, 0]). If x is complex, setting conjugate=True gives the conjugate transpose: 
x = tf.constant([[1 + 1j, 2 + 2j, 3 + 3j],
                 [4 + 4j, 5 + 5j, 6 + 6j]])
tf.transpose(x, conjugate=True)
<tf.Tensor: shape=(3, 2), dtype=complex128, numpy=
array([[1.-1.j, 4.-4.j],
       [2.-2.j, 5.-5.j],
       [3.-3.j, 6.-6.j]])>
 'perm' is more useful for n-dimensional tensors where n > 2: 
x = tf.constant([[[ 1,  2,  3],
                  [ 4,  5,  6]],
                 [[ 7,  8,  9],
                  [10, 11, 12]]])
 As above, simply calling tf.transpose will default to perm=[2,1,0]. To take the transpose of the matrices in dimension-0 (such as when you are transposing matrices where 0 is the batch dimesnion), you would set perm=[0,2,1]. 
tf.transpose(x, perm=[0, 2, 1])
<tf.Tensor: shape=(2, 3, 2), dtype=int32, numpy=
array([[[ 1,  4],
        [ 2,  5],
        [ 3,  6]],
        [[ 7, 10],
        [ 8, 11],
        [ 9, 12]]], dtype=int32)>
 
Note: This has a shorthand linalg.matrix_transpose):

 


 Args
  a   A Tensor.  
  perm   A permutation of the dimensions of a. This should be a vector.  
  conjugate   Optional bool. Setting it to True is mathematically equivalent to tf.math.conj(tf.transpose(input)).  
  name   A name for the operation (optional).   
 


 Returns   A transposed Tensor.  
 Numpy Compatibility In numpy transposes are memory-efficient constant time operations as they simply return a new view of the same data with adjusted strides. TensorFlow does not support strides, so transpose returns a new tensor with the items permuted.
tf.truncatediv Returns x / y element-wise for integer types.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.truncatediv  
tf.truncatediv(
    x, y, name=None
)
 Truncation designates that negative numbers will round fractional quantities toward zero. I.e. -7 / 5 = -1. This matches C semantics but it is different than Python semantics. See FloorDiv for a division function that matches Python Semantics. 
Note: truncatediv supports broadcasting. More about broadcasting here

 


 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.  
  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.truncatemod Returns element-wise remainder of division. This emulates C semantics in that  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.truncatemod  
tf.truncatemod(
    x, y, name=None
)
 the result here is consistent with a truncating divide. E.g. truncate(x / y) * y + truncate_mod(x, y) = x. 
Note: truncatemod supports broadcasting. More about broadcasting here

 


 Args
  x   A Tensor. Must be one of the following types: int32, int64, bfloat16, half, float32, float64.  
  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.tuple     View source on GitHub    Group tensors together. 
tf.tuple(
    tensors, control_inputs=None, name=None
)
 This creates a tuple of tensors with the same values as the tensors argument, except that the value of each tensor is only returned after the values of all tensors have been computed. control_inputs contains additional ops that have to finish before this op finishes, but whose outputs are not returned. This can be used as a "join" mechanism for parallel computations: all the argument tensors can be computed in parallel, but the values of any tensor returned by tuple are only available after all the parallel computations are done. See also tf.group and tf.control_dependencies.
 


 Args
  tensors   A list of Tensors or IndexedSlices, some entries can be None.  
  control_inputs   List of additional ops to finish before returning.  
  name   (optional) A name to use as a name_scope for the operation.   
 


 Returns   Same as tensors.  

 


 Raises
  ValueError   If tensors does not contain any Tensor or IndexedSlices.  
  TypeError   If control_inputs is not a list of Operation or Tensor objects.
Module: tf.types Public TensorFlow type definitions. For details, see https://github.com/tensorflow/community/blob/master/rfcs/20200211-tf-types.md Modules experimental module: Public API for tf.types.experimental namespace.
Module: tf.types.experimental Public API for tf.types.experimental namespace. Type Aliases TensorLike: Union of all types that can be converted to a tf.Tensor by tf.convert_to_tensor.
tf.types.experimental.TensorLike This symbol is a type alias. Union of all types that can be converted to a tf.Tensor by tf.convert_to_tensor. Source: 
TensorLike = Union[
    tensorflow.python.types.core.Tensor,
    tensorflow.python.types.core.TensorProtocol,
    int,
    float,
    bool,
    str,
    complex,
    tuple,
    list,
    numpy.ndarray
]
 This definition may be used in user code. Additional types may be added in the future as more input types are supported. Example: def foo(x: TensorLike):
  pass
 This definition passes static type verification for: foo(tf.constant([1, 2, 3]))
foo([1, 2, 3])
foo(np.array([1, 2, 3]))
tf.TypeSpec     View source on GitHub    Specifies a TensorFlow value type.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.TypeSpec, tf.compat.v1.data.experimental.Structure  A tf.TypeSpec provides metadata describing an object accepted or returned by TensorFlow APIs. Concrete subclasses, such as tf.TensorSpec and tf.RaggedTensorSpec, are used to describe different value types. For example, tf.function's input_signature argument accepts a list (or nested structure) of TypeSpecs. Creating new subclasses of TypeSpec (outside of TensorFlow core) is not currently supported. In particular, we may make breaking changes to the private methods and properties defined by this base class.
 


 Attributes
  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 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.
tf.type_spec_from_value Returns a tf.TypeSpec that represents the given value.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.type_spec_from_value  
tf.type_spec_from_value(
    value
)
 Examples: 
tf.type_spec_from_value(tf.constant([1, 2, 3]))
TensorSpec(shape=(3,), dtype=tf.int32, name=None)
tf.type_spec_from_value(np.array([4.0, 5.0], np.float64))
TensorSpec(shape=(2,), dtype=tf.float64, name=None)
tf.type_spec_from_value(tf.ragged.constant([[1, 2], [3, 4, 5]]))
RaggedTensorSpec(TensorShape([2, None]), tf.int32, 1, tf.int64)
 
example_input = tf.ragged.constant([[1, 2], [3]])
@tf.function(input_signature=[tf.type_spec_from_value(example_input)])
def f(x):
  return tf.reduce_sum(x, axis=1)

 


 Args
  value   A value that can be accepted or returned by TensorFlow APIs. Accepted types for value include tf.Tensor, any value that can be converted to tf.Tensor using tf.convert_to_tensor, and any subclass of CompositeTensor (such as tf.RaggedTensor).   
 


 Returns   A TypeSpec that is compatible with value.  

 


 Raises
  TypeError   If a TypeSpec cannot be built for value, because its type is not supported.
tf.UnconnectedGradients     View source on GitHub    Controls how gradient computation behaves when y does not depend on x.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.UnconnectedGradients  The gradient of y with respect to x can be zero in two different ways: there could be no differentiable path in the graph connecting x to y (and so we can statically prove that the gradient is zero) or it could be that runtime values of tensors in a particular execution lead to a gradient of zero (say, if a relu unit happens to not be activated). To allow you to distinguish between these two cases you can choose what value gets returned for the gradient when there is no path in the graph from x to y:  
NONE: Indicates that [None] will be returned if there is no path from x to y 
ZERO: Indicates that a zero tensor will be returned in the shape of x. 
 


 Class Variables
  NONE   tf.UnconnectedGradients  
  ZERO   tf.UnconnectedGradients
tf.unique     View source on GitHub    Finds unique elements in a 1-D tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.unique  
tf.unique(
    x, out_idx=tf.dtypes.int32, name=None
)
 This operation returns a tensor y containing all of the unique elements of x sorted in the same order that they occur in x; x does not need to be sorted. This operation also returns a tensor idx the same size as x that contains the index of each value of x in the unique output y. In other words: y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1] Examples: # tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]

# tensor 'x' is [4, 5, 1, 2, 3, 3, 4, 5]
y, idx = unique(x)
y ==> [4, 5, 1, 2, 3]
idx ==> [0, 1, 2, 3, 4, 4, 0, 1]

 


 Args
  x   A Tensor. 1-D.  
  out_idx   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int32.  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (y, idx).     y   A Tensor. Has the same type as x.  
  idx   A Tensor of type out_idx.
tf.unique_with_counts     View source on GitHub    Finds unique elements in a 1-D tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.unique_with_counts  
tf.unique_with_counts(
    x, out_idx=tf.dtypes.int32, name=None
)
 This operation returns a tensor y containing all of the unique elements of x sorted in the same order that they occur in x. This operation also returns a tensor idx the same size as x that contains the index of each value of x in the unique output y. Finally, it returns a third tensor count that contains the count of each element of y in x. In other words: y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1] For example: # tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx, count = unique_with_counts(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
count ==> [2, 1, 3, 1, 2]

 


 Args
  x   A Tensor. 1-D.  
  out_idx   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int32.  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (y, idx, count).     y   A Tensor. Has the same type as x.  
  idx   A Tensor of type out_idx.  
  count   A Tensor of type out_idx.
tf.unravel_index Converts an array of flat indices into a tuple of coordinate arrays.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.unravel_index  
tf.unravel_index(
    indices, dims, name=None
)
 Example: y = tf.unravel_index(indices=[2, 5, 7], dims=[3, 3])
# 'dims' represent a hypothetical (3, 3) tensor of indices:
# [[0, 1, *2*],
#  [3, 4, *5*],
#  [6, *7*, 8]]
# For each entry from 'indices', this operation returns
# its coordinates (marked with '*'), such as
# 2 ==> (0, 2)
# 5 ==> (1, 2)
# 7 ==> (2, 1)
y ==> [[0, 1, 2], [2, 2, 1]]

 


 Args
  indices   A Tensor. Must be one of the following types: int32, int64. An 0-D or 1-D int Tensor whose elements are indices into the flattened version of an array of dimensions dims.  
  dims   A Tensor. Must have the same type as indices. An 1-D int Tensor. The shape of the array to use for unraveling indices.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as indices.  
 Numpy Compatibility Equivalent to np.unravel_index
tf.unstack     View source on GitHub    Unpacks the given dimension of a rank-R tensor into rank-(R-1) tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.unstack  
tf.unstack(
    value, num=None, axis=0, name='unstack'
)
 Unpacks num tensors from value by chipping it along the axis dimension. If num is not specified (the default), it is inferred from value's shape. If value.shape[axis] is not known, ValueError is raised. For example, given a tensor of shape (A, B, C, D); If axis == 0 then the i'th tensor in output is the slice value[i, :, :, :] and each tensor in output will have shape (B, C, D). (Note that the dimension unpacked along is gone, unlike split). If axis == 1 then the i'th tensor in output is the slice value[:, i, :, :] and each tensor in output will have shape (A, C, D). Etc. This is the opposite of stack.
 


 Args
  value   A rank R > 0 Tensor to be unstacked.  
  num   An int. The length of the dimension axis. Automatically inferred if None (the default).  
  axis   An int. The axis to unstack along. Defaults to the first dimension. Negative values wrap around, so the valid range is [-R, R).  
  name   A name for the operation (optional).   
 


 Returns   The list of Tensor objects unstacked from value.  

 


 Raises
  ValueError   If num is unspecified and cannot be inferred.  
  ValueError   If axis is out of the range [-R, R).
tf.Variable.SaveSliceInfo     View source on GitHub    Information on how to save this Variable as a slice.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.Variable.SaveSliceInfo  
tf.Variable.SaveSliceInfo(
    full_name=None, full_shape=None, var_offset=None, var_shape=None,
    save_slice_info_def=None, import_scope=None
)
 Provides internal support for saving variables as slices of a larger variable. This API is not public and is subject to change. Available properties:  full_name full_shape var_offset var_shape 
 


 Args
  full_name   Name of the full variable of which this Variable is a slice.  
  full_shape   Shape of the full variable, as a list of int.  
  var_offset   Offset of this Variable into the full variable, as a list of int.  
  var_shape   Shape of this Variable, as a list of int.  
  save_slice_info_def   SaveSliceInfoDef protocol buffer. If not None, recreates the SaveSliceInfo object its contents. save_slice_info_def and other arguments are mutually exclusive.  
  import_scope   Optional string. Name scope to add. Only used when initializing from protocol buffer.   
 


 Attributes
  spec   Computes the spec string used for saving.    Methods to_proto View source 
to_proto(
    export_scope=None
)
 Returns a SaveSliceInfoDef() proto.
 


 Args
  export_scope   Optional string. Name scope to remove.   
 


 Returns   A SaveSliceInfoDef protocol buffer, or None if the Variable is not in the specified name scope.
tf.VariableAggregation     View source on GitHub    Indicates how a distributed variable will be aggregated. tf.distribute.Strategy distributes a model by making multiple copies (called "replicas") acting data-parallel on different elements of the input batch. When performing some variable-update operation, say var.assign_add(x), in a model, we need to resolve how to combine the different values for x computed in the different replicas.  
NONE: This is the default, giving an error if you use a variable-update operation with multiple replicas. 
SUM: Add the updates across replicas. 
MEAN: Take the arithmetic mean ("average") of the updates across replicas. 
ONLY_FIRST_REPLICA: This is for when every replica is performing the same update, but we only want to perform the update once. Used, e.g., for the global step counter. 
 


 Class Variables
  MEAN   tf.VariableAggregation  
  NONE   tf.VariableAggregation  
  ONLY_FIRST_REPLICA   tf.VariableAggregation  
  SUM   tf.VariableAggregation
tf.VariableSynchronization     View source on GitHub    Indicates when a distributed variable will be synced.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.VariableSynchronization   
AUTO: Indicates that the synchronization will be determined by the current DistributionStrategy (eg. With MirroredStrategy this would be ON_WRITE). 
NONE: Indicates that there will only be one copy of the variable, so there is no need to sync. 
ON_WRITE: Indicates that the variable will be updated across devices every time it is written. 
ON_READ: Indicates that the variable will be aggregated across devices when it is read (eg. when checkpointing or when evaluating an op that uses the variable). 
 


 Class Variables
  AUTO   tf.VariableSynchronization  
  NONE   tf.VariableSynchronization  
  ON_READ   tf.VariableSynchronization  
  ON_WRITE   tf.VariableSynchronization
tf.variable_creator_scope     View source on GitHub    Scope which defines a variable creation function to be used by variable(). 
@tf_contextlib.contextmanager
tf.variable_creator_scope(
    variable_creator
)
 variable_creator is expected to be a function with the following signature: def variable_creator(next_creator, **kwargs)
 The creator is supposed to eventually call the next_creator to create a variable if it does want to create a variable and not call Variable or ResourceVariable directly. This helps make creators composable. A creator may choose to create multiple variables, return already existing variables, or simply register that a variable was created and defer to the next creators in line. Creators can also modify the keyword arguments seen by the next creators. Custom getters in the variable scope will eventually resolve down to these custom creators when they do create variables. The valid keyword arguments in kwds are:  initial_value: A Tensor, or Python object convertible to a Tensor, which is the initial value for the Variable. The initial value must have a shape specified unless validate_shape is set to False. Can also be a callable with no argument that returns the initial value when called. In that case, dtype must be specified. (Note that initializer functions from init_ops.py must first be bound to a shape before being used here.) trainable: If True, the default, GradientTapes automatically watch uses of this Variable. validate_shape: If False, allows the variable to be initialized with a value of unknown shape. If True, the default, the shape of initial_value must be known. caching_device: Optional device string describing where the Variable should be cached for reading. Defaults to the Variable's device. If not None, caches on another device. Typical use is to cache on the device where the Ops using the Variable reside, to deduplicate copying through Switch and other conditional statements. name: Optional name for the variable. Defaults to 'Variable' and gets uniquified automatically. dtype: If set, initial_value will be converted to the given type. If None, either the datatype will be kept (if initial_value is a Tensor), or convert_to_tensor will decide. constraint: A constraint function to be applied to the variable after updates by some algorithms. synchronization: Indicates when a distributed a variable will be aggregated. Accepted values are constants defined in the class tf.VariableSynchronization. By default the synchronization is set to AUTO and the current DistributionStrategy chooses when to synchronize. aggregation: Indicates how a distributed variable will be aggregated. Accepted values are constants defined in the class tf.VariableAggregation.  This set may grow over time, so it's important the signature of creators is as mentioned above.
 


 Args
  variable_creator   the passed creator   
 


 Yields   A scope in which the creator is active
Module: tf.version Public API for tf.version namespace.
 


 Other Members
  COMPILER_VERSION   '7.3.1 20180303'  
  GIT_VERSION   'v2.4.0-rc4-71-g582c8d236cb'  
  GRAPH_DEF_VERSION   561  
  GRAPH_DEF_VERSION_MIN_CONSUMER   0  
  GRAPH_DEF_VERSION_MIN_PRODUCER   0  
  VERSION   '2.4.0'
Module: tf.xla Public API for tf.xla namespace. Modules experimental module: Public API for tf.xla.experimental namespace.
Module: tf.xla.experimental Public API for tf.xla.experimental namespace. Functions compile(...): Builds an operator that compiles and runs computation with XLA. (deprecated) jit_scope(...): Enable or disable JIT compilation of operators within the scope.
tf.xla.experimental.compile     View source on GitHub    Builds an operator that compiles and runs computation with XLA. (deprecated)  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.xla.experimental.compile  
tf.xla.experimental.compile(
    computation, inputs=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: xla.experimental.compile is deprecated. Consider using tf.function(experimental_compile=True)
Note: In eager mode, computation will have @tf.function semantics.

 


 Args
  computation   A Python function that builds a computation to apply to the input. If the function takes n inputs, 'inputs' should be a list of n tensors. computation may return a list of operations and tensors. Tensors must come before operations in the returned list. The return value of compile is a list of tensors corresponding to the tensors from the output of computation. All Operations returned from computation will be executed when evaluating any of the returned output tensors. 
 
  inputs   A list of inputs or None (equivalent to an empty list). Each input can be a nested structure containing values that are convertible to tensors. Note that passing an N-dimension list of compatible values will result in a N-dimension list of scalar tensors rather than a single Rank-N tensors. If you need different behavior, convert part of inputs to tensors with tf.convert_to_tensor.   
 


 Returns   Same data structure as if computation(*inputs) is called directly with some exceptions for correctness. Exceptions include: 1) None output: a NoOp would be returned which control-depends on computation. 2) Single value output: A tuple containing the value would be returned. 3) Operation-only outputs: a NoOp would be returned which control-depends on computation. 
 

 


 Raises
  RuntimeError   if called when eager execution is enabled.    Known issues: When a tf.random operation is built with XLA, the implementation doesn't pass the user provided seed to the XLA compiler. As such, the XLA compiler generates a random number and uses it as a seed when compiling the operation. This implementation causes a violation of the Tensorflow defined semantics in two aspects. First, changing the value of the user defined seed doesn't change the numbers generated by the operation. Second, when a seed is not specified, running the program multiple times will generate the same numbers.