class_docstr: Strategy for training with multiple processes in parallel.
docstr: Blocks ddp sync gradients behaviour on backwards pass.
  
  This is useful for skipping sync when accumulating gradients, reducing communication overhead
  Returns: context manager with sync behaviour off
docstr_tok: ["Blocks","ddp","sync","gradients","behaviour","on","backwards","pass",".","This","is","useful","for","skipping","sync","when","accumulating","gradients",",","reducing","communication","overhead","Returns",":","context","manager","with","sync","behaviour","off"]
code: def block_backward_sync(self) -> Generator:
      """Blocks ddp sync gradients behaviour on backwards pass.
  
      This is useful for skipping sync when accumulating gradients, reducing communication overhead
      Returns: context manager with sync behaviour off
  
      """
      if isinstance(
          self.model, pl.utilities.types.DistributedDataParallel
      ):
          with self.model.no_sync():
              yield None
      else:
          yield None
  
imports: from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from typing import Any, Dict, Generator, List, Optional
  import torch
  from torch import Tensor
  from typing_extensions import override
  import lightning.pytorch
  from lightning.fabric.plugins import CheckpointIO, ClusterEnvironment
  from lightning.fabric.utilities.distributed import ReduceOp, _all_gather_ddp_if_available
  from lightning.pytorch.plugins import LayerSync
  from lightning.pytorch.plugins.precision import Precision
  from lightning.pytorch.strategies.strategy import Strategy
label_desc: Use image node_id 13 for calling the ParallelStrategy obj's underlying member method code with example usage: obj.block_backward_sync() without return types