code: def shard(rows, rank, num_workers):
      """Only return every num_workers example for distributed training."""
      queue = []
      for row in rows:
          queue.append(row)
          # might discard remainder %num_workers rows because distributed
          # training needs to be in sync
          if len(queue) == num_workers:
              yield queue[rank]
              queue = []
  
imports: import itertools
  from collections import Counter
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytext.common.constants import SpecialTokens, Token
  from pytext.utils import cuda, precision
label_desc: Use image node_id 6 for calling a global function with example usage: shard(rows, rank, num_workers) without return types