class_docstr: Flatten an iterable object to a list in a lazy-evaluation way.
  
  Notes
  =====
  
  This class is an iterator with which the memory cost can be economised.
  Optimisation has been considered to ameliorate the performance for some
  specific data types like DenseNDimArray and SparseNDimArray.
  
  Examples
  ========
  
  >>> from sympy.tensor.array.arrayop import Flatten
  >>> from sympy.tensor.array import Array
  >>> A = Array(range(6)).reshape(2, 3)
  >>> Flatten(A)
  Flatten([[0, 1, 2], [3, 4, 5]])
  >>> [i for i in Flatten(A)]
  [0, 1, 2, 3, 4, 5]
class_docstr_tok: ["Flatten","an","iterable","object","to","a","list","in","a","lazy-evaluation","way",".","Notes","=====","This","class","is","an","iterator","with","which","the","memory","cost","can","be","economised",".","Optimisation","has","been","considered","to","ameliorate","the","performance","for","some","specific","data","types","like","DenseNDimArray","and","SparseNDimArray",".","Examples","========",">",">",">","from","sympy.tensor.array.arrayop","import","Flatten",">",">",">","from","sympy.tensor.array","import","Array",">",">",">","A","=","Array","(","range","(","6",")",")",".reshape","(","2",",","3",")",">",">",">","Flatten","(","A",")","Flatten","(","[","[","0",",","1",",","2","]",",","[","3",",","4",",","5","]","]",")",">",">",">","[","i","for","i","in","Flatten","(","A",")","]","[","0",",","1",",","2",",","3",",","4",",","5","]"]
code: def __next__(self):
      from sympy.matrices.matrixbase import MatrixBase
  
      if len(self._iter) > self._idx:
          if isinstance(self._iter, DenseNDimArray):
              result = self._iter._array[self._idx]
  
          elif isinstance(self._iter, SparseNDimArray):
              if self._idx in self._iter._sparse_array:
                  result = self._iter._sparse_array[self._idx]
              else:
                  result = 0
  
          elif isinstance(self._iter, MatrixBase):
              result = self._iter[self._idx]
  
          elif hasattr(self._iter, "__next__"):
              result = next(self._iter)
  
          else:
              result = self._iter[self._idx]
  
      else:
          raise StopIteration
  
      self._idx += 1
      return result
  
imports: import itertools
  from collections.abc import Iterable
  from sympy.core._print_helpers import Printable
  from sympy.core.containers import Tuple
  from sympy.core.function import diff
  from sympy.core.singleton import S
  from sympy.core.sympify import _sympify
  from sympy.tensor.array.ndim_array import NDimArray
  from sympy.tensor.array.dense_ndim_array import DenseNDimArray, ImmutableDenseNDimArray
  from sympy.tensor.array.sparse_ndim_array import SparseNDimArray
label_desc: Use image node_id 3 for calling the Flatten obj's underlying member method code with example usage: obj.__next__() and returns: result