class_docstr: EfficientDet keras network with train and test step.
docstr: Initialize model.
docstr_tok: ["Initialize","model","."]
code: def __init__(self, model_name=None, params=None, name=""):
      """Initialize model."""
      super().__init__(name=name)
  
      self.train_metrics = {
          "mean_loss_tracker": tf.keras.metrics.Mean(name="mean_loss"),
          "loss_tracker": tf.keras.metrics.Mean(name="loss"),
          "lr_tracker": tf.keras.metrics.Mean(name="lr"),
      }
      self.train_metrics = utils.dict_to_namedtuple(self.train_metrics)
      self.mAP_tracker = tf.keras.metrics.Mean(name="mAP")
  
      if params:
          self.config = hparams_config.Config(params)
      else:
          self.config = hparams_config.get_efficientdet_config(
              model_name
          )
  
      config = self.config
  
      # Backbone.
      backbone_name = config.backbone_name
      if "efficientnet" in backbone_name:
          override_params = {
              "relu_fn": functools.partial(
                  utils.activation_fn, act_type=config.act_type
              ),
              "grad_checkpoint": self.config.grad_checkpoint,
          }
          if "b0" in backbone_name:
              override_params["survival_prob"] = 0.0
          if config.backbone_config is not None:
              override_params[
                  "blocks_args"
              ] = efficientnet_builder.BlockDecoder().encode(
                  config.backbone_config.blocks
              )
          override_params["data_format"] = config.data_format
          self.backbone = efficientnet_builder.get_model(
              backbone_name, override_params=override_params
          )
  
      # Feature network.
      self.resample_layers = []  # additional resampling layers.
      for level in range(6, config.max_level + 1):
          # Adds a coarser level by downsampling the last feature map.
          self.resample_layers.append(
              layers.ResampleFeatureMap(
                  feat_level=(level - config.min_level),
                  target_num_channels=config.fpn_num_filters,
                  apply_bn=config.apply_bn_for_resampling,
                  conv_after_downsample=config.conv_after_downsample,
                  data_format=config.data_format,
                  name="resample_p%d" % level,
              )
          )
      self.fpn_cells = layers.FPNCells(config)
  
      # class/box output prediction network.
      num_anchors = len(config.aspect_ratios) * config.num_scales
      num_filters = config.fpn_num_filters
      self.class_net = layers.ClassNet(
          num_classes=config.num_classes,
          num_anchors=num_anchors,
          num_filters=num_filters,
          min_level=config.min_level,
          max_level=config.max_level,
          act_type=config.act_type,
          repeats=config.box_class_repeats,
          separable_conv=config.separable_conv,
          survival_prob=config.survival_prob,
          grad_checkpoint=config.grad_checkpoint,
          data_format=config.data_format,
      )
  
      self.box_net = layers.BoxNet(
          num_anchors=num_anchors,
          num_filters=num_filters,
          min_level=config.min_level,
          max_level=config.max_level,
          act_type=config.act_type,
          repeats=config.box_class_repeats,
          separable_conv=config.separable_conv,
          survival_prob=config.survival_prob,
          grad_checkpoint=config.grad_checkpoint,
          data_format=config.data_format,
      )
  
imports: import functools
  from absl import logging
  import tensorflow
  import hparams_config
  import utils
  from .backbone import efficientnet_builder
  from .utils import postprocess
  from .utils import layers
  from .utils import losses
  import re
label_desc: Use image node_id 1 to create a new EfficientDetNet object from inherited base classes: tf.keras with example: obj = EfficientDetNet(model_name, params, name)