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: Create a copy of the classifier that can be refit from scratch. Will inherit same architecture, optimizer and
  initialization as cloned model, but without weights.
  
  :return: new estimator
docstr_tok: ["Create","a","copy","of","the","classifier","that","can","be","refit","from","scratch",".","Will","inherit","same","architecture",",","optimizer","and","initialization","as","cloned","model",",","but","without","weights",".",":","return",":","new","estimator"]
code: def clone_for_refitting(
      self,
  ) -> "TensorFlowV2Classifier":  # pragma: no cover
      """
      Create a copy of the classifier that can be refit from scratch. Will inherit same architecture, optimizer and
      initialization as cloned model, but without weights.
  
      :return: new estimator
      """
      import tensorflow as tf
  
      try:
          # only works for functionally defined models
          model = tf.keras.models.clone_model(
              self.model, input_tensors=self.model.inputs
          )
      except ValueError as error:
          raise ValueError(
              "Cannot clone custom tensorflow models"
          ) from error
  
      optimizer = self.model.optimizer
      # reset optimizer variables
      for var in optimizer.variables():
          var.assign(tf.zeros_like(var))
  
      model.compile(
          optimizer=optimizer,
          loss=self.model.loss,
          metrics=self.model.metrics,
          loss_weights=self.model.compiled_loss._loss_weights,  # pylint: disable=W0212
          weighted_metrics=self.model.compiled_metrics._weighted_metrics,  # pylint: disable=W0212
          run_eagerly=self.model.run_eagerly,
      )
  
      clone = type(self)(model, self.nb_classes, self.input_shape)
      params = self.get_params()
      del params["model"]
      clone.set_params(**params)
      clone._train_step = self._train_step  # pylint: disable=W0212
      clone._reduce_labels = (
          self._reduce_labels
      )  # pylint: disable=W0212
      clone._loss_object = self._loss_object  # pylint: disable=W0212
      clone._optimizer = self._optimizer  # pylint: disable=W0212
      return clone
  
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 14 for calling the TensorFlowV2Classifier obj's underlying member method code with example usage: obj.clone_for_refitting() and returns: clone