code: def test_arrayexpr_convert_index_to_array_support_function():
      expr = M[i, j]
      assert _convert_indexed_to_array(expr) == (M, (i, j))
      expr = M[i, j] * N[k, l]
      assert _convert_indexed_to_array(expr) == (
          ArrayTensorProduct(M, N),
          (i, j, k, l),
      )
      expr = M[i, j] * N[j, k]
      assert _convert_indexed_to_array(expr) == (
          ArrayDiagonal(ArrayTensorProduct(M, N), (1, 2)),
          (i, k, j),
      )
      expr = Sum(M[i, j] * N[j, k], (j, 0, k - 1))
      assert _convert_indexed_to_array(expr) == (
          ArrayContraction(ArrayTensorProduct(M, N), (1, 2)),
          (i, k),
      )
      expr = M[i, j] + N[i, j]
      assert _convert_indexed_to_array(expr) == (ArrayAdd(M, N), (i, j))
      expr = M[i, j] + N[j, i]
      assert _convert_indexed_to_array(expr) == (
          ArrayAdd(M, PermuteDims(N, Permutation([1, 0]))),
          (i, j),
      )
      expr = M[i, j] + M[j, i]
      assert _convert_indexed_to_array(expr) == (
          ArrayAdd(M, PermuteDims(M, Permutation([1, 0]))),
          (i, j),
      )
      expr = (M * N * P)[i, j]
      assert _convert_indexed_to_array(expr) == (
          _array_contraction(
              ArrayTensorProduct(M, N, P), (1, 2), (3, 4)
          ),
          (i, j),
      )
      expr = expr.function  # Disregard summation in previous expression
      ret1, ret2 = _convert_indexed_to_array(expr)
      assert ret1 == ArrayDiagonal(
          ArrayTensorProduct(M, N, P), (1, 2), (3, 4)
      )
      assert str(ret2) == "(i, j, _i_1, _i_2)"
      expr = KroneckerDelta(i, j) * M[i, k]
      assert _convert_indexed_to_array(expr) == (M, ({i, j}, k))
      expr = KroneckerDelta(i, j) * KroneckerDelta(j, k) * M[i, l]
      assert _convert_indexed_to_array(expr) == (M, ({i, j, k}, l))
      expr = KroneckerDelta(j, k) * (
          M[i, j] * N[k, l] + N[i, j] * M[k, l]
      )
      assert _convert_indexed_to_array(expr) == (
          _array_diagonal(
              _array_add(
                  ArrayTensorProduct(M, N),
                  _permute_dims(
                      ArrayTensorProduct(M, N), Permutation(0, 2)(1, 3)
                  ),
              ),
              (1, 2),
          ),
          (i, l, frozenset({j, k})),
      )
      expr = (
          KroneckerDelta(j, m)
          * KroneckerDelta(m, k)
          * (M[i, j] * N[k, l] + N[i, j] * M[k, l])
      )
      assert _convert_indexed_to_array(expr) == (
          _array_diagonal(
              _array_add(
                  ArrayTensorProduct(M, N),
                  _permute_dims(
                      ArrayTensorProduct(M, N), Permutation(0, 2)(1, 3)
                  ),
              ),
              (1, 2),
          ),
          (i, l, frozenset({j, m, k})),
      )
      expr = (
          KroneckerDelta(i, j)
          * KroneckerDelta(j, k)
          * KroneckerDelta(k, m)
          * M[i, 0]
          * KroneckerDelta(m, n)
      )
      assert _convert_indexed_to_array(expr) == (
          M,
          ({i, j, k, m, n}, 0),
      )
      expr = M[i, i]
      assert _convert_indexed_to_array(expr) == (
          ArrayDiagonal(M, (0, 1)),
          (i,),
      )
  
file_path: sympy/sympy/tensor/array/expressions/tests/test_convert_indexed_to_array.py
imports: from sympy import tanh
  from sympy.concrete.summations import Sum
  from sympy.core.symbol import symbols
  from sympy.functions.special.tensor_functions import KroneckerDelta
  from sympy.matrices.expressions.matexpr import MatrixSymbol
  from sympy.matrices.expressions.special import Identity
  from sympy.tensor.array.expressions import ArrayElementwiseApplyFunc
  from sympy.tensor.indexed import IndexedBase
  from sympy.combinatorics import Permutation
  from sympy.tensor.array.expressions.array_expressions import ArrayContraction, ArrayTensorProduct, ArrayDiagonal, ArrayAdd, PermuteDims, ArrayElement, _array_tensor_product, _array_contraction, _array_diagonal, _array_add, _permute_dims, ArraySymbol, OneArray
  from sympy.tensor.array.expressions.from_array_to_matrix import convert_array_to_matrix
  from sympy.tensor.array.expressions.from_indexed_to_array import convert_indexed_to_array, _convert_indexed_to_array
  from sympy.testing.pytest import raises
label_desc: Use image node_id 1 for calling a global function with example usage: test_arrayexpr_convert_index_to_array_support_function() without return types