class_docstr: Callback for logging Keras Core training metrics to MLflow.
  
  This callback logs model metadata at training begins, and logs training metrics every epoch or
  every n steps (defined by the user) to MLflow.
  
  Args:
      run: an 'mlflow.entities.run.Run' instance, the MLflow run.
      log_every_epoch: bool, If True, log metrics every epoch. If False, log metrics every n
          steps.
      log_every_n_steps: int, log metrics every n steps. If None, log metrics every epoch. Must
          be `None` if `log_every_epoch=True`.
  
  .. code-block:: python
      :caption: Example
  
      import keras_core as keras
      import mlflow
      import numpy as np
  
      # Prepare data for a 2-class classification.
      data = np.random.uniform([8, 28, 28, 3])
      label = np.random.randint(2, size=8)
      model = keras.Sequential(
          [
              keras.Input([28, 28, 3]),
              keras.layers.Flatten(),
              keras.layers.Dense(2),
          ]
      )
      model.compile(
          loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
          optimizer=keras.optimizers.Adam(0.001),
          metrics=[keras.metrics.SparseCategoricalAccuracy()],
      )
      with mlflow.start_run() as run:
          model.fit(
              data,
              label,
              batch_size=4,
              epochs=2,
              callbacks=[mlflow.keras_core.MLflowCallback(run)],
          )
docstr: Log model architecture and optimizer configuration when training begins.
docstr_tok: ["Log","model","architecture","and","optimizer","configuration","when","training","begins","."]
code: def on_train_begin(self, logs=None):
      """Log model architecture and optimizer configuration when training begins."""
      config = self.model.optimizer.get_config()
      log_params({f"optimizer_{k}": v for k, v in config.items()})
  
      model_summary = []
  
      def print_fn(line, *args, **kwargs):
          model_summary.append(line)
  
      self.model.summary(print_fn=print_fn)
      summary = "\n".join(model_summary)
      log_text(summary, artifact_file="model_summary.txt")
  
file_path: mlflow/mlflow/keras_core/callback.py
imports: import keras_core
  from mlflow import log_params, log_text
  from mlflow.utils.autologging_utils import BatchMetricsLogger
label_desc: Use image node_id 2 for calling the MLflowCallback obj's underlying member method code with example usage: obj.on_train_begin(logs) without return types