class_docstr: TFTrainer is a simple but feature-complete training and eval loop for TensorFlow, optimized for 🤗 Transformers.
  
  Args:
      model ([`TFPreTrainedModel`]):
          The model to train, evaluate or use for predictions.
      args ([`TFTrainingArguments`]):
          The arguments to tweak training.
      train_dataset ([`~tf.data.Dataset`], *optional*):
          The dataset to use for training. The dataset should yield tuples of `(features, labels)` where `features`
          is a dict of input features and `labels` is the labels. If `labels` is a tensor, the loss is calculated by
          the model by calling `model(features, labels=labels)`. If `labels` is a dict, such as when using a
          QuestionAnswering head model with multiple targets, the loss is instead calculated by calling
          `model(features, **labels)`.
      eval_dataset ([`~tf.data.Dataset`], *optional*):
          The dataset to use for evaluation. The dataset should yield tuples of `(features, labels)` where `features`
          is a dict of input features and `labels` is the labels. If `labels` is a tensor, the loss is calculated by
          the model by calling `model(features, labels=labels)`. If `labels` is a dict, such as when using a
          QuestionAnswering head model with multiple targets, the loss is instead calculated by calling
          `model(features, **labels)`.
      compute_metrics (`Callable[[EvalPrediction], Dict]`, *optional*):
          The function that will be used to compute metrics at evaluation. Must take a [`EvalPrediction`] and return
          a dictionary string to metric values.
      tb_writer (`tf.summary.SummaryWriter`, *optional*):
          Object to write to TensorBoard.
      optimizers (`Tuple[tf.keras.optimizers.Optimizer, tf.keras.optimizers.schedules.LearningRateSchedule]`, *optional*):
          A tuple containing the optimizer and the scheduler to use. The optimizer default to an instance of
          [`tf.keras.optimizers.Adam`] if `args.weight_decay_rate` is 0 else an instance of [`AdamWeightDecay`]. The
          scheduler will default to an instance of [`tf.keras.optimizers.schedules.PolynomialDecay`] if
          `args.num_warmup_steps` is 0 else an instance of [`WarmUp`].
code: def __init__(
      self,
      model: TFPreTrainedModel,
      args: TFTrainingArguments,
      train_dataset: Optional[tf.data.Dataset] = None,
      eval_dataset: Optional[tf.data.Dataset] = None,
      compute_metrics: Optional[
          Callable[[EvalPrediction], Dict]
      ] = None,
      tb_writer: Optional[tf.summary.SummaryWriter] = None,
      optimizers: Tuple[
          tf.keras.optimizers.Optimizer,
          tf.keras.optimizers.schedules.LearningRateSchedule,
      ] = (
          None,
          None,
      ),
  ):
      self.model = model
      self.args = args
      self.train_dataset = train_dataset
      self.eval_dataset = eval_dataset
      self.compute_metrics = compute_metrics
      self.optimizer, self.lr_scheduler = optimizers
      self.gradient_accumulator = GradientAccumulator()
      self.global_step = 0
      self.epoch_logging = 0
      self.eval_loss = tf.keras.metrics.Sum()
  
      warnings.warn(
          "The class `TFTrainer` is deprecated and will be removed in version 5 of Transformers. "
          "We recommend using native Keras instead, by calling methods like `fit()` and `predict()` "
          "directly on the model object. Detailed examples of the Keras style can be found in our "
          "examples at https://github.com/huggingface/transformers/tree/main/examples/tensorflow",
          FutureWarning,
      )
  
      if tb_writer is not None:
          self.tb_writer = tb_writer
      else:
          self.tb_writer = tf.summary.create_file_writer(
              self.args.logging_dir
          )
  
      if is_wandb_available():
          self.setup_wandb()
      elif (
          os.getenv("WANDB_DISABLED", "").upper()
          not in ENV_VARS_TRUE_VALUES
      ):
          logger.info(
              "You are instantiating a Trainer but W&B is not installed. To use wandb logging, "
              "run `pip install wandb && wandb login` see https://docs.wandb.com/huggingface."
          )
  
      if is_comet_available():
          self.setup_comet()
      elif os.environ.get("COMET_MODE") != "DISABLED":
          logger.info(
              "To use comet_ml logging, run `pip/conda install comet_ml` "
              "see https://www.comet.ml/docs/python-sdk/huggingface/"
          )
  
      enable_full_determinism(
          self.args.seed
      ) if self.args.full_determinism else set_seed(self.args.seed)
  
imports: import datetime
  import math
  import os
  import warnings
  from typing import Callable, Dict, Optional, Tuple
  from .utils import ENV_VARS_TRUE_VALUES
  from .integrations import is_comet_available, is_wandb_available
  import numpy
  import tensorflow
  from tensorflow.python.distribute.values import PerReplica
  from .modeling_tf_utils import TFPreTrainedModel
  from .optimization_tf import GradientAccumulator, create_optimizer
  from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, IntervalStrategy, PredictionOutput, enable_full_determinism, set_seed
  from .training_args_tf import TFTrainingArguments
  from .utils import logging
label_desc: Use image node_id 1 to create a new TFTrainer object  with example: obj = TFTrainer(model, args, train_dataset, eval_dataset, compute_metrics, tb_writer, optimizers)