code: def _do_fit(
      n_samples,
      input_dim,
      n_outputs,
      epsilon,
      generator,
      batch_size,
      reset_n_samples,
      optimizer,
      loss,
      distribution="laplace",
  ):
      """Instantiate necessary components for fitting and perform a model fit.
  
      Args:
        n_samples: number of samples in dataset
        input_dim: the sample dimensionality
        n_outputs: number of output neurons
        epsilon: privacy parameter
        generator: True to create a generator, False to use an iterator
        batch_size: batch_size to use
        reset_n_samples: True to set _samples to None prior to fitting. False does
          nothing
        optimizer: instance of TestOptimizer
        loss: instance of TestLoss
        distribution: distribution to get noise from.
  
      Returns:
        BoltOnModel instsance
      """
      clf = models.BoltOnModel(n_outputs)
      clf.compile(optimizer, loss)
      if generator:
          x = _cat_dataset(
              n_samples,
              input_dim,
              n_outputs,
              batch_size,
              generator=generator,
          )
          y = None
          # x = x.batch(batch_size)
          x = x.shuffle(n_samples // 2)
          batch_size = None
          if reset_n_samples:
              n_samples = None
          clf.fit_generator(
              x,
              n_samples=n_samples,
              noise_distribution=distribution,
              epsilon=epsilon,
          )
      else:
          x, y = _cat_dataset(
              n_samples,
              input_dim,
              n_outputs,
              batch_size,
              generator=generator,
          )
          if reset_n_samples:
              n_samples = None
          clf.fit(
              x,
              y,
              batch_size=batch_size,
              n_samples=n_samples,
              noise_distribution=distribution,
              epsilon=epsilon,
          )
      return clf
  
imports: from absl.testing import parameterized
  import tensorflow.compat.v1
  from tensorflow.compat.v1.python.framework import ops
  from tensorflow.compat.v1.python.keras import keras_parameterized
  from tensorflow.compat.v1.python.keras import losses
  from tensorflow.compat.v1.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
  from tensorflow.compat.v1.python.keras.regularizers import L1L2
  from tensorflow_privacy.privacy.bolt_on import models
  from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin
  from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn
label_desc: Use image node_id 2 for calling a global function with example usage: _do_fit(n_samples, input_dim, n_outputs, epsilon, generator, batch_size, reset_n_samples, optimizer, loss, distribution) and returns: clf