docstr: Runs forward only schedule, with communication between pipeline stages.
docstr_tok: ["Runs","forward","only","schedule",",","with","communication","between","pipeline","stages","."]
code: def run_forward_only(
      self,
      model: Module,
      data_iter: Iterable,
      criterion: Callable[..., Any],
      return_loss: bool = False,
      return_outputs: bool = False,
  ) -> Dict:
      """
      Runs forward only schedule, with communication between pipeline stages.
      """
      assert self.forward_only
  
      self.load_batch(data_iter)
  
      accum_loss = None
      if return_loss and self.stage_manager.is_last_stage():
          accum_loss = torch.scalar_tensor(
              0, device=get_current_device()
          )
      outputs = (
          []
          if return_outputs and self.stage_manager.is_last_stage()
          else None
      )
  
      for _ in range(self.num_microbatches):
          input_obj = self.recv_forward()
          output_obj = self.forward_step(
              model, input_obj, criterion, accum_loss, outputs
          )
          self.send_forward(output_obj)
  
      if outputs is not None:
          if isinstance(model, ModelWrapper):
              model = model.unwrap()
          outputs = merge_batch(
              outputs, getattr(model, "batch_size_dim", 0)
          )
      return {"loss": accum_loss, "outputs": outputs}
  
imports: from functools import partial
  from typing import Any, Callable, Dict, Iterable, List, Optional, Union
  import torch
  import torch.cuda
  from torch.nn import Module
  from torch.utils._pytree import tree_map
  from colossalai.interface import ModelWrapper, OptimizerWrapper
  from colossalai.pipeline.p2p import PipelineP2PCommunication, create_send_metadata
  from colossalai.pipeline.stage_manager import PipelineStageManager
  from colossalai.utils.device import get_current_device
  from ._utils import detach, get_batch_size, get_micro_batch, merge_batch, model_forward, retain_grad, to_device, tree_map_hf
  from .base import PipelineSchedule
label_desc: Use image node_id 12 for calling the OneForwardOneBackwardSchedule obj's underlying member method code with example usage: obj.run_forward_only(model, data_iter, criterion, return_loss, return_outputs) and returns: dict