code: def apply_default_prefetch(input_source_or_dataflow, trainer):
      """
      Apply a set of default rules to make a fast :class:`InputSource`.
  
      Args:
          input_source_or_dataflow(InputSource | DataFlow):
          trainer (Trainer):
  
      Returns:
          InputSource
      """
      if not isinstance(input_source_or_dataflow, InputSource):
          # to mimic same behavior of the old trainer interface
          if type(trainer) == SimpleTrainer:
              input = FeedInput(input_source_or_dataflow)
          else:
              logger.info(
                  "Automatically applying QueueInput on the DataFlow."
              )
              input = QueueInput(input_source_or_dataflow)
      else:
          input = input_source_or_dataflow
      if hasattr(trainer, "devices"):
          towers = trainer.devices
          if len(towers) > 1:  # seem to only help on >1 GPUs
              assert not isinstance(trainer, SimpleTrainer)
  
              if isinstance(input, QueueInput):
                  logger.info(
                      "Automatically applying StagingInput on the DataFlow."
                  )
                  input = StagingInput(input)
      return input
  
file_path: tensorpack/tensorpack/train/interface.py
imports: from ..compat import tfv1
  from ..input_source import FeedInput, InputSource, QueueInput, StagingInput
  from ..utils import logger
  from ..compat import is_tfv2
  from .config import TrainConfig
  from .tower import SingleCostTrainer
  from .trainers import SimpleTrainer
label_desc: Use image node_id 1 for calling a global function with example usage: apply_default_prefetch(input_source_or_dataflow, trainer) and returns: input