code: def _maybe_set_distributed_sampler_epoch(
      dataloader: Iterable[object],
      current_epoch: int,
  ) -> None:
      """Set epoch of distributed sampler in dataloader, if applicable.
      See: https://pytorch.org/docs/stable/data.html#torch.utils.data.distributed.DistributedSampler
      """
      # Set current training epoch for any DistributedSampler in dataloader
      if isinstance(
          dataloader, torch.utils.data.DataLoader
      ) and isinstance(
          dataloader.sampler,
          torch.utils.data.distributed.DistributedSampler,
      ):
          dataloader.sampler.set_epoch(current_epoch)
  
file_path: tnt/torchtnt/framework/_loop_utils.py
imports: import collections
  import inspect
  import logging
  from typing import Callable, Dict, Iterable, Optional, TypeVar
  import torch
  import torch.nn
  import typing_extensions
  from torchtnt.framework.state import State
  from torchtnt.utils.progress import Progress
label_desc: Use image node_id 3 for calling a global function with example usage: _maybe_set_distributed_sampler_epoch(dataloader, current_epoch) without return types