def __init__(
      self,
      tensor: Optional[Text] = None,
      tuple_index: Optional[int] = None,
      rank: Optional[int] = None,
      shape: Optional[Sequence[Union[int, Text, Unchecked]]] = None,
      static_dims: Optional[Sequence[int]] = None,
      bounding_shape: Optional[Sequence[Union[int, Text, Unchecked]]] = None,
      shape_of: Optional[Text] = None,
      dtype: Optional[Union[tf.dtypes.DType, Sequence[tf.dtypes.DType]]] = None,
      dtype_of: Optional[Text] = None,
      is_tensor: bool = True,
      optional: bool = False,
      vanilla_tensor: bool = False,
      ragged: bool = False,
      row_splits_dtype: Optional[tf.dtypes.DType] = None,
      var: Optional[tf.Tensor] = None,
      var_name: Optional[Text] = None):
    """Creates `Require` contract spec for use within a `tc.contract` decorator.

    These same options apply to `Ensure`, but `tensor` must be specified as
    `tc.RESULT` for `Ensure`.

    Args:
      tensor: Name of the function argument (in the decorated function) to be
        checked. Required unless using `var`.
      tuple_index: Index within the tuple (or list-like structure). This is
        typically used in `Ensure` conditions when multiple tensors are being
        returned.
      rank: Require that the rank of the tensor is equal to this value. Ranks
        are currently expected to be statically determinable (unlike shapes).
      shape: Require that the shape of this tensor is equal to this value.
      static_dims: Require that the dimensions indices in this list are static
        (can be determined at graph-building time), not dynamic.
      bounding_shape: For `tf.RaggedTensor`s: require that their bounding shape
        is equal to this value.
      shape_of: Checks that the shape of the tensor is exactly the same as the
        specified argument. This is especially useful for comparing
        `RaggedTensor`s such that we can compare the entire shape (including
        row lengths).
      dtype: Require that the dtype of the tensor is this type.
      dtype_of: Require that the dtype of the tensor is equal to the value of
        the function argument with this name. The function argument itself must
        be either a dtype or tensor-like.
      is_tensor: Require that `tensor` is truly tensor-like (convertible to
        tensor). This excludes structures such as tuples.
      optional: Is `None` a valid value for this tensor?
      vanilla_tensor: Require that `tensor` is a plain `tf.Tensor`. Not a list,
        numpy array, `tf.RaggedTensor`, nor `tf.SparseTensor`.
      ragged: Allow (but not require) that `tensor` can be a `tf.RaggedTensor`.
      row_splits_dtype: Require that `tensor` (which should be a
        `tf.RaggedTensor`) has the specified dtype for its row splits dtype.
      var: For use in `Dynamic` conditions only: The actual argument instance
        to place conditions on.
      var_name: The name of the variable `var`, used to produce meaningful
        error messages.
    """
    self.tensor = tensor
    self.var = var
    self.var_name = var_name
    self.tuple_index = tuple_index
    self.rank = rank
    self.shape = shape
    self.static_dims = static_dims or []
    self.bounding_shape = bounding_shape
    self.shape_of = shape_of
    self.dtype = dtype
    self.dtype_of = dtype_of
    self.is_tensor = is_tensor
    self.optional = optional
    self.vanilla_tensor = vanilla_tensor
    self.ragged = ragged
    self.row_splits_dtype = row_splits_dtype

    if var is None:
      if tensor is None:
        raise ValueError(
            "Expected `tensor` to be specified (unless `var` is specified "
            "inside a `Dynamic` contract).")
    else:
      # `var` is specified.
      if var_name is None:
        raise ValueError(
            "Expected `var_name` to be specified when `var` is specified.")
      if tensor is not None:
        raise ValueError("Exactly one of `tensor` and `var` may be specified.")
      if tuple_index is not None:
        raise ValueError("`tuple_index` may not be specified with `var`.")

    if rank is None:
      # TODO(jhclark): Add implicit rank check back once we support dynamic
      # ranks (right now we assume rank is statically determinable).
      if shape is not None:
        # self.rank = len(shape)
        pass
      elif bounding_shape is not None:
        # self.rank = len(bounding_shape)
        pass
    # TODO(jhclark): Validate that shape is consistent with rank right here
    # (i.e. fail fast).
Creates `Require` contract spec for use within a `tc.contract` decorator.

    These same options apply to `Ensure`, but `tensor` must be specified as
    `tc.RESULT` for `Ensure`.

    Args:
      tensor: Name of the function argument (in the decorated function) to be
        checked. Required unless using `var`.
      tuple_index: Index within the tuple (or list-like structure). This is
        typically used in `Ensure` conditions when multiple tensors are being
        returned.
      rank: Require that the rank of the tensor is equal to this value. Ranks
        are currently expected to be statically determinable (unlike shapes).
      shape: Require that the shape of this tensor is equal to this value.
      static_dims: Require that the dimensions indices in this list are static
        (can be determined at graph-building time), not dynamic.
      bounding_shape: For `tf.RaggedTensor`s: require that their bounding shape
        is equal to this value.
      shape_of: Checks that the shape of the tensor is exactly the same as the
        specified argument. This is especially useful for comparing
        `RaggedTensor`s such that we can compare the entire shape (including
        row lengths).
      dtype: Require that the dtype of the tensor is this type.
      dtype_of: Require that the dtype of the tensor is equal to the value of
        the function argument with this name. The function argument itself must
        be either a dtype or tensor-like.
      is_tensor: Require that `tensor` is truly tensor-like (convertible to
        tensor). This excludes structures such as tuples.
      optional: Is `None` a valid value for this tensor?
      vanilla_tensor: Require that `tensor` is a plain `tf.Tensor`. Not a list,
        numpy array, `tf.RaggedTensor`, nor `tf.SparseTensor`.
      ragged: Allow (but not require) that `tensor` can be a `tf.RaggedTensor`.
      row_splits_dtype: Require that `tensor` (which should be a
        `tf.RaggedTensor`) has the specified dtype for its row splits dtype.
      var: For use in `Dynamic` conditions only: The actual argument instance
        to place conditions on.
      var_name: The name of the variable `var`, used to produce meaningful
        error messages.
    
language/canine/tensor_contracts.py