code: def _model_ebc(
      tables: List[EmbeddingBagConfig],
      quant_device: torch.device,
      device: torch.device,
      quant_state_dict_split_scale_bias: bool,
      sharding_type: ShardingType,
      world_size: int,
      batch_size: int,
      terminal_stage: TerminalStage,
      inputs: List[KeyedJaggedTensor],
  ) -> torch.nn.Module:
      logging.info(f" _model_ebc.BEGIN[{terminal_stage}]")
      print_device_memory_allocated_status(
          f"_model_ebc.BEGIN {terminal_stage}"
      )
  
      wrapped_module = EBCWrapper(
          QuantEmbeddingBagCollection(
              tables=tables,
              is_weighted=False,
              device=quant_device,
              quant_state_dict_split_scale_bias=quant_state_dict_split_scale_bias,
          )
      )
  
      print_device_memory_allocated_status(
          f"_model_ebc.WRAPPED_MODULE {terminal_stage}"
      )
  
      if terminal_stage == TerminalStage.QUANT:
          return wrapped_module
  
      if terminal_stage == TerminalStage.FXJIT_QUANT:
          wrapped_module(inputs[0])
          graph_module = symbolic_trace(
              wrapped_module,
              leaf_modules=["IntNBitTableBatchedEmbeddingBagsCodegen"],
          )
          scripted_module = torch.jit.script(graph_module)
          return scripted_module
  
      print_device_memory_allocated_status(
          f"_model_ebc.BEFORE_SHARDING {terminal_stage}"
      )
      sharder = TestQuantEBCSharder(
          sharding_type=sharding_type.value,
          kernel_type=EmbeddingComputeKernel.QUANT.value,
          shardable_params=[table.name for table in tables],
      )
  
      topology: Topology = Topology(
          world_size=world_size, compute_device="cuda"
      )
      planner = EmbeddingShardingPlanner(
          topology=topology,
          batch_size=batch_size,
          enumerator=EmbeddingEnumerator(
              topology=topology,
              batch_size=batch_size,
              estimator=[
                  EmbeddingPerfEstimator(
                      topology=topology, is_inference=True
                  ),
                  EmbeddingStorageEstimator(topology=topology),
              ],
          ),
      )
  
      # pyre-ignore [6]
      plan = planner.plan(wrapped_module, [sharder])
  
      sharded_module = _shard_modules(
          module=wrapped_module,
          # pyre-ignore [6]
          sharders=[sharder],
          device=device,
          plan=plan,
          env=ShardingEnv.from_local(
              world_size=topology.world_size, rank=0
          ),
      )
      print_device_memory_allocated_status(
          f"_model_ebc.AFTER_SHARDING {terminal_stage}"
      )
  
      if terminal_stage == TerminalStage.SHARDED_QUANT:
          return sharded_module
  
      sharded_module(inputs[0])
      sharded_traced_module = symbolic_trace(
          sharded_module,
          leaf_modules=["IntNBitTableBatchedEmbeddingBagsCodegen"],
      )
  
      sharded_scripted_module = torch.jit.script(sharded_traced_module)
      return sharded_scripted_module
  
imports: import argparse
  import gc
  import logging
  import os
  import time
  from dataclasses import dataclass
  from enum import Enum
  from typing import Dict, List, Tuple
  import torch
  from torch.autograd.profiler import record_function
  from torchrec.distributed.embedding_types import EmbeddingComputeKernel, ShardingType
  from torchrec.distributed.planner import EmbeddingShardingPlanner, Topology
  from torchrec.distributed.planner.enumerators import EmbeddingEnumerator
  from torchrec.distributed.planner.shard_estimators import EmbeddingPerfEstimator, EmbeddingStorageEstimator
  from torchrec.distributed.shard import _shard_modules
  from torchrec.distributed.test_utils.infer_utils import TestQuantEBCSharder
  from torchrec.distributed.test_utils.test_model import ModelInput
  from torchrec.distributed.types import DataType, ShardingEnv
  from torchrec.fx import symbolic_trace
  from torchrec.modules.embedding_configs import EmbeddingBagConfig
  from torchrec.quant.embedding_modules import EmbeddingBagCollection
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor, KeyedTensor
label_desc: Use image node_id 2 for calling a global function with example usage: _model_ebc(tables, quant_device, device, quant_state_dict_split_scale_bias, sharding_type, world_size, batch_size, terminal_stage, inputs) and returns: sharded_scripted_module, wrapped_module, scripted_module, sharded_module