def fit_generator(self, generator: "DataGenerator", nb_epochs: int = 20, **kwargs) -> None:  # pragma: no cover
        """
        Fit the classifier using the generator that yields batches as specified.

        :param generator: Batch generator providing `(x, y)` for each epoch.
        :param nb_epochs: Number of epochs to use for training.
        :param kwargs: Dictionary of framework-specific arguments. This parameter is not currently supported for MXNet
               and providing it takes no effect.
        """
        import mxnet as mx
        from art.data_generators import MXDataGenerator

        if self.optimizer is None:
            raise ValueError("An MXNet optimizer is required for fitting the model.")

        training_mode = True

        if (
            isinstance(generator, MXDataGenerator)
            and (self.preprocessing is None or self.preprocessing == [])
            and self.preprocessing == (0, 1)
        ):
            # Train directly in MXNet
            for _ in range(nb_epochs):
                for x_batch, y_batch in generator.iterator:
                    x_batch = mx.nd.array(x_batch.astype(config.ART_NUMPY_DTYPE)).as_in_context(self.ctx)
                    y_batch = mx.nd.argmax(y_batch, axis=1)
                    y_batch = mx.nd.array(y_batch).as_in_context(self.ctx)

                    with mx.autograd.record(train_mode=training_mode):
                        # Perform prediction
                        preds = self._model(x_batch)

                        # Form the loss function
                        loss = self.loss(preds, y_batch)

                    loss.backward()

                    # Update parameters
                    self.optimizer.step(x_batch.shape[0])
        else:
            # Fit a generic data generator through the API
            super().fit_generator(generator, nb_epochs=nb_epochs)

        Fit the classifier using the generator that yields batches as specified.

        :param generator: Batch generator providing `(x, y)` for each epoch.
        :param nb_epochs: Number of epochs to use for training.
        :param kwargs: Dictionary of framework-specific arguments. This parameter is not currently supported for MXNet
               and providing it takes no effect.
        
art/estimators/classification/mxnet.py