`repr` error on empty BCOO sparse matrix
I tried to initialize an empty BCOO matrix by:
```
from jax.experimental import sparse as jsparse
import jax.numpy as jnp

M = jsparse.BCOO((jnp.array([]), jnp.array([])), shape=(100, 100))
```

Just using the repr on `M` gives the following error: `<repr(<jax.experimental.sparse.ops.BCOO at 0x7f15fb4c9590>) failed: IndexError: tuple index out of range>`, which is unexpected.

On the other hand, initializing `M` with

```M = jsparse.BCOO((jnp.zeros(0, dtype='float32'), jnp.zeros((0, 2), dtype='int32')), shape=(100, 100)) ```

gives the correct repr output
```
M
BCOO(float32[100, 100], nse=0)
```


diff --git a/jax/experimental/sparse/ops.py b/jax/experimental/sparse/ops.py
index 1b2c2c0e2..d6983ab04 100644
--- a/jax/experimental/sparse/ops.py
+++ b/jax/experimental/sparse/ops.py
@@ -1394,7 +1394,15 @@ class JAXSparse:
     self.shape = shape
 
   def __repr__(self):
-    repr_ = f"{self.__class__.__name__}({self.dtype}{list(self.shape)}, nse={self.nse})"
+    name = self.__class__.__name__
+    try:
+      nse = self.nse
+      dtype = self.dtype
+      shape = list(self.shape)
+    except:
+      repr_ = f"{name}(<invalid>)"
+    else:
+      repr_ = f"{name}({dtype}{shape}, nse={nse})"
     if isinstance(self.data, core.Tracer):
       repr_ = f"{type(self.data).__name__}[{repr_}]"
     return repr_
diff --git a/tests/sparse_test.py b/tests/sparse_test.py
index e7592830b..060b44488 100644
--- a/tests/sparse_test.py
+++ b/tests/sparse_test.py
@@ -1113,6 +1113,13 @@ class SparseGradTest(jtu.JaxTestCase):
 
 
 class SparseObjectTest(jtu.JaxTestCase):
+  def test_repr(self):
+    M = sparse.BCOO.fromdense(jnp.arange(5, dtype='float32'))
+    assert repr(M) == "BCOO(float32[5], nse=4)"
+
+    M_invalid = sparse.BCOO(([], []), shape=100)
+    assert repr(M_invalid) == "BCOO(<invalid>)"
+
   @parameterized.named_parameters(
     {"testcase_name": "_{}".format(Obj.__name__), "Obj": Obj}
     for Obj in [sparse.CSR, sparse.CSC, sparse.COO, sparse.BCOO])
['tests/sparse_test.py', 'jax/experimental/sparse/ops.py']