code: def init(
      model: Model[InT, InT],
      X: Optional[Array3d] = None,
      Y: Optional[Array3d] = None,
  ) -> None:
      layer = model.layers[0]
      if X is None and Y is None:
          layer.initialize()
      X2d: Optional[Array2d] = None
      Y2d: Optional[Array2d] = None
      if X is not None:
          X2d = cast(Array2d, model.ops.reshape(X, (-1, X.shape[-1])))
      if Y is not None:
          Y2d = cast(Array2d, model.ops.reshape(Y, (-1, Y.shape[-1])))
      layer.initialize(X=X2d, Y=Y2d)
      if layer.has_dim("nI"):
          model.set_dim("nI", layer.get_dim("nI"))
      if layer.has_dim("nO"):
          model.set_dim("nO", layer.get_dim("nO"))
  
imports: from typing import Callable, List, Optional, Tuple, TypeVar, cast
  from ..config import registry
  from ..model import Model
  from ..types import Array2d, Array3d
label_desc: Use image node_id 3 for calling a global function with example usage: init(model, X, Y) without return types