class_docstr: This is a wrapper around PG that provides a series of features around object collectives.
  
  It works without distributed initialized, where most collectives turns into nops.
  
  All variants that take functions are exception robust, meaning that if one or more
  ranks raise errors, all ranks will observe those.
class_docstr_tok: ["This","is","a","wrapper","around","PG","that","provides","a","series","of","features","around","object","collectives",".","It","works","without","distributed","initialized",",","where","most","collectives","turns","into","nops",".","All","variants","that","take","functions","are","exception","robust",",","meaning","that","if","one","or","more","ranks","raise","errors",",","all","ranks","will","observe","those","."]
docstr: Implement functionality similar to c10d::gather_object but without distributed enabled.
docstr_tok: ["Implement","functionality","similar","to","c10d",":",":gather_object","but","without","distributed","enabled","."]
code: def gather_object(self, object: T) -> Optional[List[T]]:
      """Implement functionality similar to c10d::gather_object but without distributed enabled."""
      if self.use_dist:
          gather_objs = (
              cast(List[T], [None] * dist.get_world_size(self.group))
              if self.is_coordinator
              else None
          )
  
          dist.gather_object(
              obj=object,
              object_gather_list=gather_objs
              if self.is_coordinator
              else None,
              dst=self.coordinator_rank,
              group=self.group,
          )
          result = gather_objs
      else:
          result = [object]
      return result
  
imports: import cProfile
  import io
  import itertools
  import os
  from contextlib import contextmanager
  from pstats import Stats
  from typing import Any, Callable, cast, Dict, List, Optional, Sequence, TypeVar, Union
  import torch
  import torch.distributed
  from torch.distributed._shard.sharded_tensor import ShardedTensor
  from torch.distributed._shard.sharded_tensor.shard import Shard
  from torch.distributed._tensor import DTensor
  from .api import _is_wrapped_exception, _wrap_exception, CheckpointException, WRAPPED_EXCEPTION
  from .metadata import MetadataIndex, STATE_DICT_TYPE
label_desc: Use image node_id 5 for calling the _DistWrapper obj's underlying member method code with example usage: obj.gather_object(object) and returns: result