code: def make_sharded_object_for_checkpoint(
      obj: Any,
      key: str,
      sharded_offsets: Iterable[Tuple[int, int, int]] = (),
      replica_id: Union[None, int, Tuple[int, ...]] = None,
      **kwargs,
  ):
      """Helper for instantiating a non-sharded ShardedObject (replicated across TP and DP group).
  
      Arguments:
          obj (object): any object to be sharded
          key (str): unique identifier of the object
          sharded_offsets (Iterable[Tuple[int, int, int]]): offsets normally
              prepended to ShardedTensors, will be used as global offsets for
              ShardedObject
          replica_id (Union[None, int, Tuple[int, ...]]): replica id
      """
      if replica_id is None:
          replica_id = (
              0,
              parallel_state.get_tensor_model_parallel_rank(),
              parallel_state.get_data_parallel_rank(
                  with_context_parallel=True
              ),
          )
  
      return ShardedObject(
          key,
          obj,
          *_get_extra_state_offsets(sharded_offsets),
          replica_id,
          **kwargs,
      )
  
file_path: megatron-lm/megatron/core/transformer/utils.py
imports: from operator import itemgetter
  from typing import Any, Dict, Iterable, Optional, Tuple, Union
  import torch
  from megatron.core import parallel_state
  from megatron.core.dist_checkpointing.mapping import ShardedObject, StateDict
  from megatron.core.utils import make_sharded_tensor_for_checkpoint, make_tp_sharded_tensor_for_checkpoint
label_desc: Use image node_id 7 for calling a global function with example usage: make_sharded_object_for_checkpoint(obj, key, sharded_offsets, replica_id) and returns: ShardedObject