code: def init(
      model: Model[InT, OutT],
      X: Optional[InT] = None,
      Y: Optional[OutT] = None,
  ) -> None:
      if X is None and Y is None:
          for layer in model.layers:
              layer.initialize()
          if model.layers[0].has_dim("nI"):
              model.set_dim("nI", model.layers[0].get_dim("nI"))
  
      # Try to set nO on each layer, where available.
      # All layers have the same input, and the output should map directly from the
      # given Y, if provided.
      for ii, layer in enumerate(model.layers):
          if Y is not None and layer.has_dim("nO") is None:
              layer.initialize(X=X, Y=Y[ii])
          else:
              layer.initialize(X=X)
  
      if model.layers[0].has_dim("nI"):
          model.set_dim("nI", model.layers[0].get_dim("nI"))
  
imports: from typing import Any, Optional, Tuple, TypeVar
  from ..config import registry
  from ..model import Model
label_desc: Use image node_id 3 for calling a global function with example usage: init(model, X, Y) without return types