class_docstr: Task object for tf-ranking BERT.
class_docstr_tok: ["Task","object","for","tf-ranking","BERT","."]
docstr: Load a pretrained checkpoint (if exists) and then train from iter 0.
code: def initialize(self, model):
      """Load a pretrained checkpoint (if exists) and then train from iter 0."""
      ckpt_dir_or_file = self.task_config.init_checkpoint
      if tf.io.gfile.isdir(ckpt_dir_or_file):
          ckpt_dir_or_file = tf.train.latest_checkpoint(
              ckpt_dir_or_file
          )
      if not ckpt_dir_or_file:
          return
  
      pretrain2finetune_mapping = {
          "encoder": model.checkpoint_items["encoder"],
      }
      ckpt = tf.train.Checkpoint(**pretrain2finetune_mapping)
      status = ckpt.read(ckpt_dir_or_file)
      status.expect_partial().assert_existing_objects_matched()
      logging.info(
          "Finished loading pretrained checkpoint from %s",
          ckpt_dir_or_file,
      )
  
imports: import dataclasses
  import os
  import time
  from typing import Dict, Mapping, Optional, Tuple
  from absl import logging
  import numpy
  import tensorflow
  from official.core import task_factory
  from official.modeling.hyperparams import base_config
  from official.nlp.configs import encoders
  from tensorflow_ranking.extension import task
  from tensorflow_ranking.python.keras import metrics
  from tensorflow_ranking.python.keras import model
label_desc: Use image node_id 11 for calling the TFRBertTask obj's underlying member method code with example usage: obj.initialize(model) without return types