class_docstr: Step that reduces a dimension instead of manually looping on it.
  
  Using this step is equivalent to doing `sum(dact_data, [])` for each dact_data
  that might be a IDT, DIT, or EOT of a DACT (DAtaConTainer) to flatten the data,
  then the data is by default unflattened at the end of the loop in _did_process.
class_docstr_tok: ["Step","that","reduces","a","dimension","instead","of","manually","looping","on","it",".","Using","this","step","is","equivalent","to","doing","`","sum","(","dact_data",",","[","]",")","`","for","each","dact_data","that","might","be","a","IDT",",","DIT",",","or","EOT","of","a","DACT","(","DAtaConTainer",")","to","flatten","the","data",",","then","the","data","is","by","default","unflattened","at","the","end","of","the","loop","in","_did_process","."]
docstr: Data consitency checks.
code: def _invariant(self, augmented_dact, flattened_dact):
      """
      Data consitency checks.
      """
      _raise = False
      if flattened_dact.di is not None:
          if flattened_dact.eo is not None and len(
              flattened_dact.di
          ) != len(flattened_dact.eo):
              if all(v is None for v in flattened_dact.eo):
                  flattened_dact.eo = [None] * len(flattened_dact.di)
              else:
                  _raise = True
          if flattened_dact._ids is not None and len(
              flattened_dact.di
          ) != len(flattened_dact._ids):
              _raise = True
      if _raise:
          raise ValueError(
              f"FlattenForEach: Cannot flatten or unflatten data properly. Expected outputs has a "
              f"different len than data inputs for flattened DACT: {flattened_dact}, and for "
              f"augmented DACT: {augmented_dact}."
          )
  
imports: import copy
  from operator import itemgetter
  from typing import Callable, List, Optional, Tuple, Union
  from neuraxle.base import CX, DACT, BaseStep, BaseTransformer, ForceHandleMixin, ForceHandleOnlyMixin, Identity, MetaStep, NamedStepsList, TruncableJoblibStepSaver
  from neuraxle.data_container import DIT, EOT, IDT, DACTData, ListDataContainer
  from neuraxle.steps.flow import ExecuteIf
  import numpy
label_desc: Use image node_id 6 for calling the FlattenForEach obj's underlying member method code with example usage: obj._invariant(augmented_dact, flattened_dact) without return types