code: def transform_to_sharded_model(
      gm: ColoGraphModule,
      meta_args: Dict,
      solution: List[int],
      device_mesh: DeviceMesh,
      strategies_constructor: StrategiesConstructor,
      overlap: bool = False,
  ):
      """
      This method is used to transform the original graph to the sharded graph.
      The model parameters will be sharded according to the solution and the grad hooks
      will be added to the sharded graph using the runtime_preparation_pass.
      The communication node will be added into the graph using the runtime_apply_pass.
      """
      (
          gm,
          sharding_spec_dict,
          origin_spec_dict,
          comm_actions_dict,
      ) = runtime_preparation_pass(
          gm,
          solution,
          device_mesh,
          strategies_constructor,
          overlap=overlap,
      )
      gm = runtime_apply_pass(gm)
      shape_prop_pass(
          gm,
          *meta_args.values(),
          sharding_spec_dict,
          origin_spec_dict,
          comm_actions_dict,
      )
      gm.recompile()
      sharding_spec_dicts = (
          sharding_spec_dict,
          origin_spec_dict,
          comm_actions_dict,
      )
  
      return gm, sharding_spec_dicts
  
imports: from typing import Dict, List, Tuple
  import torch
  import torch.distributed
  import torch.nn
  from torch.fx.graph import Graph
  from colossalai._analyzer.fx.codegen import ActivationCheckpointCodeGen
  from colossalai._analyzer.fx.graph_module import ColoGraphModule
  from colossalai._analyzer.fx.passes import shape_prop_pass
  from colossalai._analyzer.fx.tracer.tracer import ColoTracer
  from colossalai.auto_parallel.passes.runtime_apply_pass import runtime_apply_pass
  from colossalai.auto_parallel.passes.runtime_preparation_pass import runtime_preparation_pass
  from colossalai.auto_parallel.tensor_shard.options import DataloaderOption, ShardOption, SolverOptions, SolverPerference
  from colossalai.auto_parallel.tensor_shard.sharding_strategy import CommAction
  from colossalai.auto_parallel.tensor_shard.solver import CostGraph, Solver, StrategiesConstructor
  from colossalai.device.alpha_beta_profiler import AlphaBetaProfiler
  from colossalai.device.device_mesh import DeviceMesh
  from colossalai.tensor.sharding_spec import ShardingSpec
label_desc: Use image node_id 5 for calling a global function with example usage: transform_to_sharded_model(gm, meta_args, solution, device_mesh, strategies_constructor, overlap) and returns: gm,  sharding_spec_dicts