code: def _(expr: ArrayTensorProduct, x: Expr):
      args = expr.args
      addend_list = []
      for i, arg in enumerate(expr.args):
          darg = array_derive(arg, x)
          if darg == 0:
              continue
          args_prev = args[:i]
          args_succ = args[i + 1 :]
          shape_prev = reduce(
              operator.add, map(get_shape, args_prev), ()
          )
          shape_succ = reduce(
              operator.add, map(get_shape, args_succ), ()
          )
          addend = _array_tensor_product(*args_prev, darg, *args_succ)
          tot1 = len(get_shape(x))
          tot2 = tot1 + len(shape_prev)
          tot3 = tot2 + len(get_shape(arg))
          tot4 = tot3 + len(shape_succ)
          perm = (
              list(range(tot1, tot2))
              + list(range(tot1))
              + list(range(tot2, tot3))
              + list(range(tot3, tot4))
          )
          addend = _permute_dims(addend, _af_invert(perm))
          addend_list.append(addend)
      if len(addend_list) == 1:
          return addend_list[0]
      elif len(addend_list) == 0:
          return S.Zero
      else:
          return _array_add(*addend_list)
  
imports: import operator
  from functools import reduce, singledispatch
  from sympy.core.expr import Expr
  from sympy.core.singleton import S
  from sympy.matrices.expressions.hadamard import HadamardProduct
  from sympy.matrices.expressions.inverse import Inverse
  from sympy.matrices.expressions.matexpr import MatrixExpr, MatrixSymbol
  from sympy.matrices.expressions.special import Identity, OneMatrix
  from sympy.matrices.expressions.transpose import Transpose
  from sympy.combinatorics.permutations import _af_invert
  from sympy.matrices.expressions.applyfunc import ElementwiseApplyFunction
  from sympy.tensor.array.expressions.array_expressions import _ArrayExpr, ZeroArray, ArraySymbol, ArrayTensorProduct, ArrayAdd, PermuteDims, ArrayDiagonal, ArrayElementwiseApplyFunc, get_rank, get_shape, ArrayContraction, _array_tensor_product, _array_contraction, _array_diagonal, _array_add, _permute_dims, Reshape
  from sympy.tensor.array.expressions.from_matrix_to_array import convert_matrix_to_array
label_desc: Use image node_id 3 for calling a global function with example usage: _(expr, x) and returns: addend_list, S, _array_add