code: def create_train_state(
      rng: KeyArray, config: ConfigDict
  ) -> train_state.TrainState:
      """Creates initial `TrainState`."""
      cnn = CNN()
      params = cnn.init(rng, jnp.ones([1, 28, 28, 1]))["params"]
      tx = optax.sgd(config.learning_rate, config.momentum)
      return train_state.TrainState.create(
          apply_fn=cnn.apply, params=params, tx=tx
      )
  
imports: from __future__ import annotations
  import argparse
  import os
  import typing
  from typing import TYPE_CHECKING
  import attrs
  import cattrs
  import jax
  import jax.numpy
  import numpy
  import optax
  import tensorflow_datasets
  from flax import linen
  from flax import serialization
  from flax.metrics import tensorboard
  from flax.training import train_state
  import bentoml
  from bentoml._internal.utils.pkg import pkg_version_info
label_desc: Use image node_id 5 for calling a global function with example usage: create_train_state(rng, config) and returns: train_state