docstr: Args:
      optimizer (tf.train.Optimizer):
      loss, metrics: string or list of strings
docstr_tok: ["Args",":","optimizer","(","tf.train.Optimizer",")",":","loss",",","metrics",":","string","or","list","of","strings"]
code: def compile(self, optimizer, loss, metrics=None):
      """
      Args:
          optimizer (tf.train.Optimizer):
          loss, metrics: string or list of strings
      """
      if isinstance(loss, six.string_types):
          loss = [loss]
      if metrics is None:
          metrics = []
      if isinstance(metrics, six.string_types):
          metrics = [metrics]
  
      self._stats_to_inference = loss + metrics + [TOTAL_LOSS_NAME]
      setup_keras_trainer(
          self.trainer,
          get_model=self.get_model,
          input_signature=self.input_signature,
          target_signature=self.target_signature,
          input=self.input,
          optimizer=optimizer,
          loss=loss,
          metrics=metrics,
      )
  
imports: from contextlib import contextmanager
  import six
  import tensorflow
  from tensorflow import keras
  from ..callbacks import Callback, CallbackToHook, InferenceRunner, InferenceRunnerBase, ScalarStats
  from ..models.regularize import regularize_cost_from_collection
  from ..tfutils.collection import backup_collection, restore_collection
  from ..tfutils.common import get_op_tensor_name
  from ..tfutils.scope_utils import cached_name_scope
  from ..tfutils.summary import add_moving_summary
  from ..tfutils.tower import get_current_tower_context
  from ..train import SimpleTrainer, SyncMultiGPUTrainerParameterServer, Trainer
  from ..train.interface import apply_default_prefetch
  from ..train.trainers import DistributedTrainerBase
  from ..utils import logger
  from ..utils.gpu import get_nr_gpu
label_desc: Use image node_id 2 for calling the KerasModel obj's underlying member method code with example usage: obj.compile(optimizer, loss, metrics) without return types