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`].
docstr: Setup the optimizer and the learning rate scheduler.
  
  We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
  TFTrainer's init through `optimizers`, or subclass and override this method.
docstr_tok: ["Setup","the","optimizer","and","the","learning","rate","scheduler",".","We","provide","a","reasonable","default","that","works","well",".","If","you","want","to","use","something","else",",","you","can","pass","a","tuple","in","the","TFTrainer","'s","init","through","`","optimizers","`",",","or","subclass","and","override","this","method","."]
code: def create_optimizer_and_scheduler(self, num_training_steps: int):
      """
      Setup the optimizer and the learning rate scheduler.
  
      We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
      TFTrainer's init through `optimizers`, or subclass and override this method.
      """
      if not self.optimizer and not self.lr_scheduler:
          warmup_steps = (
              self.args.warmup_steps
              if self.args.warmup_steps > 0
              else math.ceil(
                  num_training_steps * self.args.warmup_ratio
              )
          )
  
          self.optimizer, self.lr_scheduler = create_optimizer(
              self.args.learning_rate,
              num_training_steps,
              warmup_steps,
              adam_beta1=self.args.adam_beta1,
              adam_beta2=self.args.adam_beta2,
              adam_epsilon=self.args.adam_epsilon,
              weight_decay_rate=self.args.weight_decay,
              power=self.args.poly_power,
          )
  
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 5 for calling the TFTrainer obj's underlying member method code with example usage: obj.create_optimizer_and_scheduler(num_training_steps) without return types