code: def get_shard_range(dataset_size: int, rank: int, world_size: int):
      """
      In case dataset_size is not evenly divided by world_size, we need to pad
      one extra example in each shard
      shard_len = dataset_size // world_size + 1
  
      Case 1 rank < remainder: each shard start position is rank * shard_len
  
      Case 2 rank >= remainder: without padding, each shard start position is
      rank * (shard_len - 1) + remainder = rank * shard_len - (rank - remainder)
      But to make sure all shard have same size, we need to pad one extra example
      when rank >= remainder, so start_position = start_position - 1
  
      For example, dataset_size = 21, world_size = 8
      rank 0 to 4: [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]
      rank 5 to 7: [14, 15, 16], [16, 17, 18], [18, 19, 20]
      """
      remainder = dataset_size % world_size
      shard_len = dataset_size // world_size
  
      if remainder == 0:
          shard_offset = rank * shard_len
      else:
          # take one extra when dataset_size is not evenly divided by world_size
          shard_len += 1
          shard_offset = rank * shard_len - max(0, rank + 1 - remainder)
      shard_end = shard_offset + shard_len - 1
  
      return (shard_offset, shard_end)
  
imports: from datetime import timedelta
  import pytext.utils.cuda
  import torch
  import torch.distributed
label_desc: Use image node_id 4 for calling a global function with example usage: get_shard_range(dataset_size, rank, world_size) and returns: shard_offset,  shard_end