code: def with_flatten_v2(
      layer: Model[FlatT[InItemT], FlatT[OutItemT]]
  ) -> Model[NestedT[InItemT], NestedT[OutItemT]]:
      return Model(
          f"with_flatten({layer.name})",
          forward,
          layers=[layer],
          init=init,
      )
  
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 1 for calling a global function with example usage: with_flatten_v2(layer) and returns: Model