code: def _flatten(
      nested: NestedT[ItemT],
  ) -> Tuple[FlatT[ItemT], List[int]]:
      flat: List = []
      lens: List[int] = []
      for item in nested:
          flat.extend(item)
          lens.append(len(item))
      return cast(FlatT[ItemT], flat), lens
  
imports: from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar, cast
  from ..config import registry
  from ..model import Model
label_desc: Use image node_id 3 for calling a global function with example usage: _flatten(nested) and returns: cast,  lens