Repository: cupy/cupy

Issue:
einsum indices don't allow np.int
### Description

If calling `cupy.einsum` with something that contains something integer-like as list entries, like `np.int`, I get the error

```
File "/home/ssemper/.local/lib/python3.7/site-packages/cupy/linalg/_einsum.py", line 62, in _parse_int_subscript
'each subscript must be either an integer or an ellipsis',
```

whereas the same code is executing just fine with `numpy.einsum`. In my case specifically it was `numpy.int64`.

### To Reproduce

```py
# cupy.einsum(cupy.random.randn(4,3), np.arange(2), cupy.random.randn(3,5), np.arange(1,3), [0,2])
```


### Installation

_No response_

### Environment

```
[ssemper@maurice scripts]$ intelpython3 -c 'import cupy; cupy.show_config()'
OS                           : Linux-5.10.100-2-MANJARO-x86_64-with-arch-Manjaro-Linux
Python Version               : 3.7.9
CuPy Version                 : 10.0.0
CuPy Platform                : NVIDIA CUDA
NumPy Version                : 1.19.2+intel.0
SciPy Version                : 1.7.3
Cython Build Version         : 0.29.24
Cython Runtime Version       : 0.29.21
CUDA Root                    : /opt/cuda
nvcc PATH                    : /opt/cuda/bin/nvcc
CUDA Build Version           : 11050
CUDA Driver Version          : 11060
CUDA Runtime Version         : 11060
cuBLAS Version               : (available)
cuFFT Version                : 10600
cuRAND Version               : 10209
cuSOLVER Version             : (11, 3, 2)
cuSPARSE Version             : (available)
NVRTC Version                : (11, 6)
Thrust Version               : 101301
CUB Build Version            : 101301
Jitify Build Version         : 60e9e72
cuDNN Build Version          : (not loaded; try `import cupy.cuda.cudnn` first)
cuDNN Version                : (not loaded; try `import cupy.cuda.cudnn` first)
NCCL Build Version           : None
NCCL Runtime Version         : None
cuTENSOR Version             : None
cuSPARSELt Build Version     : None
Device 0 Name                : NVIDIA GeForce RTX 3090
Device 0 Compute Capability  : 86
Device 0 PCI Bus ID          : 0000:01:00.0
```


### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/cupy/linalg/_einsum.py b/cupy/linalg/_einsum.py
--- a/cupy/linalg/_einsum.py
+++ b/cupy/linalg/_einsum.py
@@ -1,5 +1,6 @@
 import copy
 import itertools
+import operator
 import string
 import warnings
 
@@ -55,12 +56,14 @@ def _parse_int_subscript(list_subscript):
     for s in list_subscript:
         if s is Ellipsis:
             str_subscript += '@'
-        elif isinstance(s, int):
-            str_subscript += einsum_symbols[s]
         else:
-            raise TypeError(
-                'each subscript must be either an integer or an ellipsis'
-                ' to provide subscripts strings as lists')
+            try:
+                s = operator.index(s)
+            except TypeError as e:
+                raise TypeError(
+                    'For this input type lists must contain '
+                    'either int or Ellipsis') from e
+            str_subscript += einsum_symbols[s]
     return str_subscript
 
 


Test patch:
diff --git a/tests/cupy_tests/linalg_tests/test_einsum.py b/tests/cupy_tests/linalg_tests/test_einsum.py
--- a/tests/cupy_tests/linalg_tests/test_einsum.py
+++ b/tests/cupy_tests/linalg_tests/test_einsum.py
@@ -283,6 +283,26 @@ def test_too_many_dims3(self):
                 xp.einsum(xp.arange(6).reshape(2, 3), [Ellipsis, 0, 1, 2])
 
 
+@pytest.mark.parametrize('do_opt', [False, True])
+class TestListArgEinSum:
+    # numpy/numpy#15961: should accept int64 type in subscript list
+    @testing.with_requires('numpy>=1.19')
+    @testing.numpy_cupy_allclose()
+    def test_numpy_15961_array(self, xp, do_opt):
+        n = 3
+        a = testing.shaped_arange((n, n), xp)
+        sub = numpy.array([0, 0])
+        return xp.einsum(a, sub, optimize=do_opt)
+
+    @testing.with_requires('numpy>=1.19')
+    @testing.numpy_cupy_allclose()
+    def test_numpy_15961_list(self, xp, do_opt):
+        n = 3
+        a = testing.shaped_arange((n, n), xp)
+        sub = list(numpy.array([0, 0]))
+        return xp.einsum(a, sub, optimize=do_opt)
+
+
 @testing.parameterize(*augment_einsum_testcases(
     {'shape_a': (2, 3), 'subscripts': 'ij'},  # do nothing
     {'shape_a': (2, 3), 'subscripts': '...'},  # do nothing