code: def _extract_delta(expr, index):
      """
      Extract a simple KroneckerDelta from the expression.
  
      Explanation
      ===========
  
      Returns the tuple ``(delta, newexpr)`` where:
  
        - ``delta`` is a simple KroneckerDelta expression if one was found,
          or ``None`` if no simple KroneckerDelta expression was found.
  
        - ``newexpr`` is a Mul containing the remaining terms; ``expr`` is
          returned unchanged if no simple KroneckerDelta expression was found.
  
      Examples
      ========
  
      >>> from sympy import KroneckerDelta
      >>> from sympy.concrete.delta import _extract_delta
      >>> from sympy.abc import x, y, i, j, k
      >>> _extract_delta(4*x*y*KroneckerDelta(i, j), i)
      (KroneckerDelta(i, j), 4*x*y)
      >>> _extract_delta(4*x*y*KroneckerDelta(i, j), k)
      (None, 4*x*y*KroneckerDelta(i, j))
  
      See Also
      ========
  
      sympy.functions.special.tensor_functions.KroneckerDelta
      deltaproduct
      deltasummation
      """
      if not _has_simple_delta(expr, index):
          return (None, expr)
      if isinstance(expr, KroneckerDelta):
          return (expr, S.One)
      if not expr.is_Mul:
          raise ValueError("Incorrect expr")
      delta = None
      terms = []
  
      for arg in expr.args:
          if delta is None and _is_simple_delta(arg, index):
              delta = arg
          else:
              terms.append(arg)
      return (delta, expr.func(*terms))
  
file_path: sympy/sympy/concrete/delta.py
imports: from .products import product
  from .summations import Sum, summation
  from sympy.core import Add, Mul, S, Dummy
  from sympy.core.cache import cacheit
  from sympy.core.sorting import default_sort_key
  from sympy.functions import KroneckerDelta, Piecewise, piecewise_fold
  from sympy.polys.polytools import factor
  from sympy.sets.sets import Interval
  from sympy.solvers.solvers import solve
label_desc: Use image node_id 2 for calling a global function with example usage: _extract_delta(expr, index) and returns: delta,  expr, None,  expr, expr,  S