def __init__(
      self,
      check_func: Callable[..., Union[tf.Tensor, bool]],
      tensors: Sequence[Union[Text, Tuple[Text, tf.Tensor]]],
      error: Text,
      error_tensors: Optional[Sequence[
          Union[Text, Tuple[Text, tf.Tensor]]]] = None,
      tensor_format: Optional[Callable[..., Sequence[tf.Tensor]]] = None,
      error_tensor_format: Optional[Callable[..., Sequence[tf.Tensor]]] = None):
    """Creates a `RequireTrue` condition.

    This is used for checking arbitrary conditions on tensors or groups of
    tensors not supported by `Require`, including invariants that inspect the
    contents of tensors at runtime. `RequireTrue` conditions returning a
    `tf.Tensor` will always be executed at runtime; conditions returning a
    python `bool` will be checked at graph building time.

    Args:
      check_func: A function that takes in the arguments specified by `tensors`
        and returns either (a) a boolean tensor, to be checked at graph
        execution time or (b) a python `bool`, to be checked immediately, at
        graph build time. For tensors, `tf.reduce_all` will be called on the
        result of `check_func`, so it's fine if the result of `check_func` is
        not rank 0. Implementors of `check_func` may wish to do additional
        type checking (e.g. asserts) to check the type of arguments since
        pytype will generally not be able to trace through the typing at this
        level. IMPORTANT: This should *NOT* be a lambda function as these are
        not supported by AutoGraph (used to construct `tf.data` pipelines).
        One exception is that lambdas seem to work fine if used inside a
        `local_invariant`.
      tensors: Typically, a sequence of strings, which names arguments to
        extract from the function that this `tc.contract` is decorating. When
        used in a `tc.Dynamic` condition, `tensors` may contain 2-tuples with
        (1) the name of the variable being passed, so that we can provide
        meaningful error messages and (2) the tensor instance to be inspected.
      error: An error message to show if this condition fails at runtime.
      error_tensors: Names of additional tensors to display if this check fails,
        to aid in debugging the failure.
      tensor_format: Function taking same number of tensors as in `tensors` and
        returning the same number of tensors, potentially formatted in some way
        to make interpreting the error message easier (e.g. `row_lengths` for
        ragged tensors).
      error_tensor_format: Like `tensor_format`, but parallel with
        `error_tensors`.
    """
    self.check_func = check_func
    self.error = error
    self.tensors = tensors
    self.error_tensors = error_tensors
    self.tensor_format = tensor_format
    self.error_tensor_format = error_tensor_format

    if not callable(check_func):
      raise ValueError("`check_func` must be a callable function.")
Creates a `RequireTrue` condition.

    This is used for checking arbitrary conditions on tensors or groups of
    tensors not supported by `Require`, including invariants that inspect the
    contents of tensors at runtime. `RequireTrue` conditions returning a
    `tf.Tensor` will always be executed at runtime; conditions returning a
    python `bool` will be checked at graph building time.

    Args:
      check_func: A function that takes in the arguments specified by `tensors`
        and returns either (a) a boolean tensor, to be checked at graph
        execution time or (b) a python `bool`, to be checked immediately, at
        graph build time. For tensors, `tf.reduce_all` will be called on the
        result of `check_func`, so it's fine if the result of `check_func` is
        not rank 0. Implementors of `check_func` may wish to do additional
        type checking (e.g. asserts) to check the type of arguments since
        pytype will generally not be able to trace through the typing at this
        level. IMPORTANT: This should *NOT* be a lambda function as these are
        not supported by AutoGraph (used to construct `tf.data` pipelines).
        One exception is that lambdas seem to work fine if used inside a
        `local_invariant`.
      tensors: Typically, a sequence of strings, which names arguments to
        extract from the function that this `tc.contract` is decorating. When
        used in a `tc.Dynamic` condition, `tensors` may contain 2-tuples with
        (1) the name of the variable being passed, so that we can provide
        meaningful error messages and (2) the tensor instance to be inspected.
      error: An error message to show if this condition fails at runtime.
      error_tensors: Names of additional tensors to display if this check fails,
        to aid in debugging the failure.
      tensor_format: Function taking same number of tensors as in `tensors` and
        returning the same number of tensors, potentially formatted in some way
        to make interpreting the error message easier (e.g. `row_lengths` for
        ragged tensors).
      error_tensor_format: Like `tensor_format`, but parallel with
        `error_tensors`.
    
language/canine/tensor_contracts.py