class_docstr: Implements data-parallel training in a single process, i.e., the model gets replicated to each device and each
  gets a split of the data.
class_docstr_tok: ["Implements","data-parallel","training","in","a","single","process",",","i.e.",",","the","model","gets","replicated","to","each","device","and","each","gets","a","split","of","the","data","."]
code: def all_reduce(
      self,
      collection: TReduce,
      group: Optional[Any] = None,
      reduce_op: Optional[Union[ReduceOp, str]] = "mean",
  ) -> TReduce:
      def mean(t: Tensor) -> Tensor:
          original_dtype = t.dtype
          return t.float().mean().to(original_dtype)
  
      return apply_to_collection(collection, Tensor, mean)
  
imports: from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch.nn import DataParallel, Module
  from typing_extensions import override
  from lightning.fabric.accelerators import Accelerator
  from lightning.fabric.plugins.io.checkpoint_io import CheckpointIO
  from lightning.fabric.plugins.precision import Precision
  from lightning.fabric.strategies.parallel import ParallelStrategy
  from lightning.fabric.strategies.registry import _StrategyRegistry
  from lightning.fabric.strategies.strategy import TBroadcast, TReduce
  from lightning.fabric.utilities.apply_func import apply_to_collection
  from lightning.fabric.utilities.distributed import ReduceOp
label_desc: Use image node_id 7 for calling the DataParallelStrategy obj's underlying member method code with example usage: obj.all_reduce(collection, group, reduce_op) and returns: apply_to_collection, t