code: def _all_gather_dtensor(
      tensor: DTensor,
      parent_mesh: Optional[DeviceMesh],
  ) -> torch.Tensor:
      """All gather a DTensor in its FSDP dimension and return the local tensor."""
      assert parent_mesh == tensor.device_mesh
  
      placements = list(copy.deepcopy(tensor.placements))
      # FSDP + TP: [Shard(0), tp_placement] -> [Replicate(), tp_placement]
      placements[0] = Replicate()
      tensor = tensor.redistribute(
          device_mesh=tensor.device_mesh,
          placements=placements,
      )
  
      return tensor.to_local()
  
imports: import copy
  from typing import Any, cast, List, Optional, Tuple
  import torch
  import torch.distributed
  import torch.distributed._shard.sharding_spec
  import torch.distributed.distributed_c10d
  from torch.distributed._shard.sharded_tensor import Shard, ShardedTensor, ShardedTensorMetadata, TensorProperties
  from torch.distributed._shard.sharding_spec import ShardMetadata
  from torch.distributed._shard.sharding_spec.chunk_sharding_spec import ChunkShardingSpec
  from torch.distributed._tensor import DeviceMesh, DTensor, Replicate, Shard
  from torch.distributed.device_mesh import _mesh_resources
  from torch.distributed.fsdp._common_utils import _set_fsdp_flattened
  from torch.distributed.fsdp._fsdp_extensions import FSDPExtensions
  from torch.distributed.fsdp._shard_utils import _create_chunk_sharded_tensor
  from torch.distributed.remote_device import _remote_device
  from torch.distributed.tensor.parallel._data_parallel_utils import _flatten_tensor, _unflatten_tensor
label_desc: Use image node_id 11 for calling a global function with example usage: _all_gather_dtensor(tensor, parent_mesh) and returns: tensor