class_docstr: This class implements a classifier with the TensorFlow v2 framework.
class_docstr_tok: ["This","class","implements","a","classifier","with","the","TensorFlow","v2","framework","."]
docstr: Fit the classifier on the training set `(x, y)`.
  
  :param x: Training data.
  :param y: Labels, one-hot-encoded of shape (nb_samples, nb_classes) or index labels of
            shape (nb_samples,).
  :param batch_size: Size of batches.
  :param nb_epochs: Number of epochs to use for training.
  :param verbose: Display training progress bar.
  :param kwargs: Dictionary of framework-specific arguments. This parameter currently supports
                 "scheduler" which is an optional function that will be called at the end of every
                 epoch to adjust the learning rate.
docstr_tok: ["Fit","the","classifier","on","the","training","set","`","(","x",",","y",")","`",".",":","param","x",":","Training","data",".",":","param","y",":","Labels",",","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","index","labels","of","shape","(","nb_samples",",",")",".",":","param","batch_size",":","Size","of","batches",".",":","param","nb_epochs",":","Number","of","epochs","to","use","for","training",".",":","param","verbose",":","Display","training","progress","bar",".",":","param","kwargs",":","Dictionary","of","framework-specific","arguments",".","This","parameter","currently","supports","``","scheduler","''","which","is","an","optional","function","that","will","be","called","at","the","end","of","every","epoch","to","adjust","the","learning","rate","."]
code: def fit(  # pylint: disable=W0221
      self,
      x: np.ndarray,
      y: np.ndarray,
      batch_size: int = 128,
      nb_epochs: int = 10,
      verbose: bool = False,
      **kwargs,
  ) -> None:
      """
      Fit the classifier on the training set `(x, y)`.
  
      :param x: Training data.
      :param y: Labels, one-hot-encoded of shape (nb_samples, nb_classes) or index labels of
                shape (nb_samples,).
      :param batch_size: Size of batches.
      :param nb_epochs: Number of epochs to use for training.
      :param verbose: Display training progress bar.
      :param kwargs: Dictionary of framework-specific arguments. This parameter currently supports
                     "scheduler" which is an optional function that will be called at the end of every
                     epoch to adjust the learning rate.
      """
      import tensorflow as tf
  
      if self._train_step is None:  # pragma: no cover
          if self._loss_object is None:  # pragma: no cover
              raise TypeError(
                  "A loss function `loss_object` or training function `train_step` is required for fitting the "
                  "model, but it has not been defined."
              )
          if self._optimizer is None:  # pragma: no cover
              raise ValueError(
                  "An optimizer `optimizer` or training function `train_step` is required for fitting the "
                  "model, but it has not been defined."
              )
  
          @tf.function
          def train_step(model, images, labels):
              with tf.GradientTape() as tape:
                  predictions = model(images, training=True)
                  loss = self.loss_object(labels, predictions)
              gradients = tape.gradient(loss, model.trainable_variables)
              self.optimizer.apply_gradients(
                  zip(gradients, model.trainable_variables)
              )
  
      else:
          train_step = self._train_step
  
      scheduler = kwargs.get("scheduler")
  
      y = check_and_transform_label_format(
          y, nb_classes=self.nb_classes
      )
  
      # Apply preprocessing
      x_preprocessed, y_preprocessed = self._apply_preprocessing(
          x, y, fit=True
      )
  
      # Check label shape
      if self._reduce_labels:
          y_preprocessed = np.argmax(y_preprocessed, axis=1)
  
      train_ds = (
          tf.data.Dataset.from_tensor_slices(
              (x_preprocessed, y_preprocessed)
          )
          .shuffle(10000)
          .batch(batch_size)
      )
  
      for epoch in tqdm(
          range(nb_epochs), disable=not verbose, desc="Epochs"
      ):
          for images, labels in train_ds:
              train_step(self.model, images, labels)
  
          if scheduler is not None:
              scheduler(epoch)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import random
  import shutil
  import time
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  from tqdm.auto import tqdm
  import numpy
  import six
  from art import config
  from art.estimators.classification.classifier import ClassGradientsMixin, ClassifierMixin
  from art.estimators.tensorflow import TensorFlowEstimator, TensorFlowV2Estimator
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 8 for calling the TensorFlowV2Classifier obj's underlying member method code with example usage: obj.fit(x, y, batch_size, nb_epochs, verbose) without return types