code: def main(args=None):
      # parse arguments
      if args is None:
          args = sys.argv[1:]
      args = parse_args(args)
  
      # create object that stores backbone information
      backbone = models.backbone(args.backbone)
  
      # make sure tensorflow is the minimum required version
      check_tf_version()
  
      # optionally choose specific GPU
      if args.gpu is not None:
          setup_gpu(args.gpu)
  
      # optionally load config parameters
      if args.config:
          args.config = read_config_file(args.config)
  
      # create the generators
      train_generator, validation_generator = create_generators(
          args, backbone.preprocess_image
      )
  
      # create the model
      if args.snapshot is not None:
          print("Loading model, this may take a second...")
          model = models.load_model(
              args.snapshot, backbone_name=args.backbone
          )
          training_model = model
          anchor_params = None
          pyramid_levels = None
          if args.config and "anchor_parameters" in args.config:
              anchor_params = parse_anchor_parameters(args.config)
          if args.config and "pyramid_levels" in args.config:
              pyramid_levels = parse_pyramid_levels(args.config)
  
          prediction_model = retinanet_bbox(
              model=model,
              anchor_params=anchor_params,
              pyramid_levels=pyramid_levels,
          )
      else:
          weights = args.weights
          # default to imagenet if nothing else is specified
          if weights is None and args.imagenet_weights:
              weights = backbone.download_imagenet()
  
          print("Creating model, this may take a second...")
          model, training_model, prediction_model = create_models(
              backbone_retinanet=backbone.retinanet,
              num_classes=train_generator.num_classes(),
              weights=weights,
              multi_gpu=args.multi_gpu,
              freeze_backbone=args.freeze_backbone,
              lr=args.lr,
              optimizer_clipnorm=args.optimizer_clipnorm,
              config=args.config,
          )
  
      # print model summary
      print(model.summary())
  
      # this lets the generator compute backbone layer shapes using the actual backbone model
      if "vgg" in args.backbone or "densenet" in args.backbone:
          train_generator.compute_shapes = make_shapes_callback(model)
          if validation_generator:
              validation_generator.compute_shapes = (
                  train_generator.compute_shapes
              )
  
      # create the callbacks
      callbacks = create_callbacks(
          model,
          training_model,
          prediction_model,
          validation_generator,
          args,
      )
  
      if not args.compute_val_loss:
          validation_generator = None
  
      # start training
      return training_model.fit_generator(
          generator=train_generator,
          steps_per_epoch=args.steps,
          epochs=args.epochs,
          verbose=1,
          callbacks=callbacks,
          workers=args.workers,
          use_multiprocessing=args.multiprocessing,
          max_queue_size=args.max_queue_size,
          validation_data=validation_generator,
          initial_epoch=args.initial_epoch,
      )
  
imports: import argparse
  import os
  import sys
  import warnings
  from tensorflow import keras
  import tensorflow
  from ..None import layers
  from ..None import losses
  from ..None import models
  from ..callbacks import RedirectModel
  from ..callbacks.eval import Evaluate
  from ..models.retinanet import retinanet_bbox
  from ..preprocessing.csv_generator import CSVGenerator
  from ..preprocessing.kitti import KittiGenerator
  from ..preprocessing.open_images import OpenImagesGenerator
  from ..preprocessing.pascal_voc import PascalVocGenerator
  from ..utils.anchors import make_shapes_callback
  from ..utils.config import read_config_file, parse_anchor_parameters, parse_pyramid_levels
  from ..utils.gpu import setup_gpu
  from ..utils.image import random_visual_effect_generator
  from ..utils.model import freeze
  from ..utils.tf_version import check_tf_version
  from ..utils.transform import random_transform_generator
label_desc: Use image node_id 8 for calling a global function with example usage: main(args) and returns: training_model