code: def ConvNeXt(
      depths,
      projection_dims,
      drop_path_rate=0.0,
      layer_scale_init_value=1e-6,
      default_size=224,
      model_name="convnext",
      include_preprocessing=True,
      include_top=True,
      weights=None,
      input_tensor=None,
      input_shape=None,
      pooling=None,
      classes=1000,
      classifier_activation="softmax",
  ):
      """Instantiates ConvNeXt architecture given specific configuration.
  
      Args:
          depths: An iterable containing depths for each individual stages.
          projection_dims: An iterable containing output number of channels of
          each individual stages.
          drop_path_rate: Stochastic depth probability. If 0.0, then stochastic
              depth won't be used.
          layer_scale_init_value: Layer scale coefficient. If 0.0, layer scaling
              won't be used.
          default_size: Default input image size.
          model_name: An optional name for the model.
          include_preprocessing: boolean denoting whther to
              include preprocessing in the model.
              When `weights="imagenet"` this should always be `True`.
              But for other models (e.g., randomly initialized) you should set it
              to `False` and apply preprocessing to data accordingly.
          include_top: Boolean denoting whether to include classification
              head to the model.
          weights: one of `None` (random initialization), `"imagenet"`
              (pre-training on ImageNet-1k),
              or the path to the weights file to be loaded.
          input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) to
              use as image input for the model.
          input_shape: optional shape tuple, only to be specified if `include_top`
              is `False`. It should have exactly 3 inputs channels.
          pooling: optional pooling mode for feature extraction when `include_top`
              is `False`.
              - `None` means that the output of the model will be
                  the 4D tensor output of the last convolutional layer.
              - `avg` means that global average pooling will be applied
                  to the output of the last convolutional layer,
                  and thus the output of the model will be a 2D tensor.
              - `max` means that global max pooling will be applied.
          classes: optional number of classes to classify images into,
              only to be specified if `include_top` is `True`,
              and if no `weights` argument is specified.
          classifier_activation: A `str` or callable.
              The activation function to use
              on the "top" layer. Ignored unless `include_top=True`.
              Set `classifier_activation=None` to return the logits
              of the "top" layer.
  
      Returns:
          A model instance.
      """
      if backend.image_data_format() == "channels_first":
          raise ValueError(
              "ConvNeXt does not support the `channels_first` image data "
              "format. Switch to `channels_last` by editing your local "
              "config file at ~/.keras/keras.json"
          )
      if not (
          weights in {"imagenet", None} or file_utils.exists(weights)
      ):
          raise ValueError(
              "The `weights` argument should be either "
              "`None` (random initialization), `imagenet` "
              "(pre-training on ImageNet), "
              "or the path to the weights file to be loaded."
          )
  
      if weights == "imagenet" and include_top and classes != 1000:
          raise ValueError(
              'If using `weights="imagenet"` with `include_top=True`, '
              "`classes` should be 1000. "
              f"Received classes={classes}"
          )
  
      # Determine proper input shape.
      input_shape = imagenet_utils.obtain_input_shape(
          input_shape,
          default_size=default_size,
          min_size=32,
          data_format=backend.image_data_format(),
          require_flatten=include_top,
          weights=weights,
      )
  
      if input_tensor is None:
          img_input = layers.Input(shape=input_shape)
      else:
          if not backend.is_keras_tensor(input_tensor):
              img_input = layers.Input(
                  tensor=input_tensor, shape=input_shape
              )
          else:
              img_input = input_tensor
  
      if input_tensor is not None:
          inputs = operation_utils.get_source_inputs(input_tensor)[0]
      else:
          inputs = img_input
  
      x = inputs
      if include_preprocessing:
          channel_axis = (
              3 if backend.image_data_format() == "channels_last" else 1
          )
          num_channels = input_shape[channel_axis - 1]
          if num_channels == 3:
              x = PreStem(name=model_name)(x)
  
      # Stem block.
      stem = Sequential(
          [
              layers.Conv2D(
                  projection_dims[0],
                  kernel_size=4,
                  strides=4,
                  name=model_name + "_stem_conv",
              ),
              layers.LayerNormalization(
                  epsilon=1e-6, name=model_name + "_stem_layernorm"
              ),
          ],
          name=model_name + "_stem",
      )
  
      # Downsampling blocks.
      downsample_layers = []
      downsample_layers.append(stem)
  
      num_downsample_layers = 3
      for i in range(num_downsample_layers):
          downsample_layer = Sequential(
              [
                  layers.LayerNormalization(
                      epsilon=1e-6,
                      name=model_name
                      + "_downsampling_layernorm_"
                      + str(i),
                  ),
                  layers.Conv2D(
                      projection_dims[i + 1],
                      kernel_size=2,
                      strides=2,
                      name=model_name + "_downsampling_conv_" + str(i),
                  ),
              ],
              name=model_name + "_downsampling_block_" + str(i),
          )
          downsample_layers.append(downsample_layer)
  
      # Stochastic depth schedule.
      # This is referred from the original ConvNeXt codebase:
      # https://github.com/facebookresearch/ConvNeXt/blob/main/models/convnext.py#L86
      depth_drop_rates = [
          float(x)
          for x in np.linspace(0.0, drop_path_rate, sum(depths))
      ]
  
      # First apply downsampling blocks and then apply ConvNeXt stages.
      cur = 0
  
      num_convnext_blocks = 4
      for i in range(num_convnext_blocks):
          x = downsample_layers[i](x)
          for j in range(depths[i]):
              x = ConvNeXtBlock(
                  projection_dim=projection_dims[i],
                  drop_path_rate=depth_drop_rates[cur + j],
                  layer_scale_init_value=layer_scale_init_value,
                  name=model_name + f"_stage_{i}_block_{j}",
              )(x)
          cur += depths[i]
  
      if include_top:
          imagenet_utils.validate_activation(
              classifier_activation, weights
          )
          x = Head(
              num_classes=classes,
              classifier_activation=classifier_activation,
              name=model_name,
          )(x)
  
      else:
          if pooling == "avg":
              x = layers.GlobalAveragePooling2D()(x)
          elif pooling == "max":
              x = layers.GlobalMaxPooling2D()(x)
          x = layers.LayerNormalization(epsilon=1e-6)(x)
  
      model = Functional(inputs=inputs, outputs=x, name=model_name)
  
      # Load weights.
      if weights == "imagenet":
          if include_top:
              file_suffix = ".h5"
              file_hash = WEIGHTS_HASHES[model_name][0]
          else:
              file_suffix = "_notop.h5"
              file_hash = WEIGHTS_HASHES[model_name][1]
          file_name = model_name + file_suffix
          weights_path = file_utils.get_file(
              file_name,
              BASE_WEIGHTS_PATH + file_name,
              cache_subdir="models",
              file_hash=file_hash,
          )
          model.load_weights(weights_path)
      elif weights is not None:
          model.load_weights(weights)
  
      return model
  
imports: import numpy
  from keras import backend
  from keras import initializers
  from keras import layers
  from keras import ops
  from keras import random
  from keras.api_export import keras_export
  from keras.applications import imagenet_utils
  from keras.layers.layer import Layer
  from keras.models import Functional
  from keras.models import Sequential
  from keras.ops import operation_utils
  from keras.utils import file_utils
label_desc: Use image node_id 4 for calling a global function with example usage: ConvNeXt(depths, projection_dims, drop_path_rate, layer_scale_init_value, default_size, model_name, include_preprocessing, include_top, weights, input_tensor, input_shape, pooling, classes, classifier_activation) and returns: model