Support mathematical operations for boolean tensors in tensorflow like in numpy
can you please explain what sort of problem is this, because the matrix multiplication of 2 tf.constants having bool type is not possible.
if possible please tell me whats wrong because i'm new to opensource hey please tell me what i did is correct or not,
`a=tnp.array([True, False])

b=tnp.array([True, True])

c=tf.cast(a,tf.float32)

d=tf.cast(b,tf.float32)

multi=c*d

div=c/d

back_to_bool=tf.cast(multi,tf.bool)

back_to_bool,div` Hey please assign this to me > hey please tell me what i did is correct or not, `a=tnp.array([True, False])
> 
> b=tnp.array([True, True])
> 
> c=tf.cast(a,tf.float32)
> 
> d=tf.cast(b,tf.float32)
> 
> multi=c*d
> 
> div=c/d
> 
> back_to_bool=tf.cast(multi,tf.bool)
> 
> back_to_bool,div`

This can be done but I want direct support for operations with bool like on Numpy
```python
>>> np.array([True, False])*np.array([True, True])
array([ True, False])
>>> np.array([True, False])/np.array([True, True])
array([1., 0.])
```
when the same is done with tf tensors, I get an error as in the issue.
I want support for tf tensors like there is in Numpy. Convert Boolean to Integer: Convert the boolean tensors to integer tensors (True to 1 and False to 0) before performing arithmetic operations.

Perform the Operation: Multiply the integer tensors.

Convert Back to Boolean (if needed): If you want the result in boolean form, convert the resulting integer tensor back to boolean.

```python
import tensorflow as tf

# Convert boolean tensors to integer tensors
tensor1 = tf.cast(tf.constant([True, False]), tf.int32)
tensor2 = tf.cast(tf.constant([True, True]), tf.int32)

# Multiply the integer tensors
result = tensor1 * tensor2

# Convert the result back to boolean
bool_result = tf.cast(result, tf.bool)

print(bool_result.numpy())  # Output: [ True False]

```  Hi @VachanVY ,

Tensorflow not supporting mathematical operations on boolean tensors. Any ways one can use tf.cast() to convert the boolean Tensors into numerics of required `dtype`. IMO, there is some flexibility here to convert into Tensors of user choice.

Also if atleast one item of the Tensor has any numeric dtype, then tf.experimental.numpy can able to convert remaining bool dtypes into given input numeric dtype which covers part of the case.

```
x = tnp.array([1,True, False])
x   # outputs: <tf.Tensor: shape=(3,), dtype=int64, numpy=array([1, 1, 0])>
x = tnp.array([1.0,True, False])
x  # outputs:<tf.Tensor: shape=(3,), dtype=float64, numpy=array([1., 1., 0.])>
```


In Numpy if you take division of bool it will give float64 and this needs to be again converted into desired dtype.

I think this is intentionally left to the users choice as multiple conversions may affect performance.

If you have come up with a use case of demonstrating the advantage of this feature or any problem with current behaviour without this feature then it might add more weightage.

Thanks!
 Hi @SuryanarayanaY, (sorry for the late response), there is as such no big advantage in adding that feature, it just makes the code less lengthy (or clean):

```python
# without feature 
>>> tf.cast(tf.cast(tf.constant([True, False]), tf.int32)* tf.cast(tf.constant([True, True]), tf.int32), bool)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])>
# with the feature
>>> tf.constant([True, False])*tf.constant([True, True])
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])>
```

And I think it's good to add the feature because `numpy` has the feature and it is good to have `numpy`-like features in `tensorflow` or at least in `tensorflow.experimental.numpy` as `tensorflow` tensors supports operations with `numpy` arrays. @VachanVY , We are reviewing internally and will update with outcome.
 Hi @VachanVY thanks for raising the issue. We do plan to add the feature in TF-NumPy. However it's a low priority given our current bandwidth. We are open to OSS contributions though.
### Issue type

bug/support

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

tf 2.13.0

### Custom code

Yes

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

3.11.4

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

```python
>>>import tensorflow as tf
>>>import numpy as np
>>>tnp = tf.experimental.numpy
>>>tf.constant([True, False])*tf.constant([True, True]) # same error for tnp.array([True, False])*tnp.array([True, True])
InvalidArgumentError                      Traceback (most recent call last)
[<ipython-input-5-5eb244ee10ef>](https://localhost:8080/#) in <cell line: 1>()
----> 1 tnp.array([True, False])*tnp.array([True, True])

1 frames
[/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py](https://localhost:8080/#) in raise_from_not_ok_status(e, name)
   5885 def raise_from_not_ok_status(e, name) -> NoReturn:
   5886   e.message += (" name: " + str(name if name is not None else ""))
-> 5887   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   5888 
   5889 

InvalidArgumentError: Value for attr 'T' of bool is not in the list of allowed values: bfloat16, half, float, double, uint8, int8, uint16, int16, int32, uint32, uint64, int64, complex64, complex128
	; NodeDef: {{node Mul}}; Op<name=Mul; signature=x:T, y:T -> z:T; attr=T:type,allowed=[DT_BFLOAT16, DT_HALF, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8, DT_UINT16, DT_INT16, DT_INT32, DT_UINT32, DT_UINT64, DT_INT64, DT_COMPLEX64, DT_COMPLEX128]; is_commutative=true> [Op:Mul] name:

>>> #but for numpy arrays this is not the case
>>> np.array([True, False])*np.array([True, True])
array([ True, False])
>>> np.array([True, False])/np.array([True, True])
array([1., 0.])
```

### Standalone code to reproduce the issue

[Google Colab link](https://colab.research.google.com/drive/1y41vpFs6Cd4NHmSY6IRmU53PXgl_SAFE?usp=sharing) 


### Relevant log output

_No response_