def METHOD_NAME(
    model_or_layer_p: pax_fiddle.Config,
) -> pax_fiddle.Config:
  """Wraps a Pax Layer PaxFiddle template to be compatible with ghost clipping.
  Note that it only replaces or wraps layers that we know are compatible. To be
  compatible, all the parameteric layers (layers with trainable parameters) in
  the model/layer need to either wrappable or replacable. Furthermore, weight
  sharing is not allowed and will cause an error even if all the others can be
  wrapped or replaced.
  Args:
    model_or_layer_p: A PaxConfig describing the model or layer to wrap.
  Returns:
    A PaxConfig describing the wrapped model.
  """
  assert isinstance(model_or_layer_p, pax_fiddle.Config)
  for attr_name in model_or_layer_p.__dir__():
    layer_p = model_or_layer_p.__getattr__(attr_name)
    if isinstance(layer_p, pax_fiddle.Config) and issubclass(
        layer_p.cls, base_layer.BaseLayer
    ):
      wrapped_layer_p = METHOD_NAME(layer_p)
      model_or_layer_p.__setattr__(attr_name, wrapped_layer_p)
  if _is_replaceable(model_or_layer_p):
    model_or_layer_p = _replace(model_or_layer_p)
  if _is_wrappable(model_or_layer_p):
    model_or_layer_p = GhostNormPaxConfig(
        WrappedGhostNorm, layer_tpl=model_or_layer_p
    )
  return model_or_layer_p