We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG]: Wrong import in ColossalAuto's meta_registry/binary_elementwise_ops.py
### 🐛 Describe the bug

# Problem description

The file `colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py` contains the following line: 

```python
from ..constants import BCAST_FUNC_OP
```

However, the file `colossalai/auto_parallel/meta_profiler/constants.py` which this import refers to does not contain any `BCAST_FUNC_OP`. This leads to an `ImportError` when running ColossalAuto in release 0.3.3 and newer. 

This constant can be found in the file `colossalai/auto_parallel/tensor_shard/constants.py`. The last commit to `colossalai/auto_parallel/meta_profiler/constants.py` (commit ID `079bf3cb`) removes the import of tensor_shard's `constants.py` from meta_profiler's `constants.py` (seemingly due to an automated refactoring).

# Solution

Since no other file in the `meta_registry` module uses constants from the `tensor_shard/constants.py` and to avoid automated removal of "unused" imports in the future, the import statement in question in above-mentioned `binary_elementwise_ops.py` could be changed to: 

```python
from colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP
```

### Environment

- Python 3.8
- Torch 1.12.0
- no CUDA

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py`
Content:
```
1 from typing import List, Tuple
2 
3 import torch
4 
5 from colossalai._analyzer._subclasses.flop_tensor import flop_mapping
6 from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size
7 from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem
8 
9 from ..constants import BCAST_FUNC_OP
10 from ..registry import meta_register
11 
12 __all__ = ["binary_elementwise_meta_info"]
13 
14 
15 @meta_register.register(BCAST_FUNC_OP)
16 def binary_elementwise_meta_info(*args, **kwargs) -> Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]:
17     """Meta information generator for binary elementwise operations
18     NOTE: Some of the binary elementwise operations will discard the input activation after computation, as they
19     don't need those tensors for back propagation, for example, if there are two tensors being sent for `torch.add`,
20     they will be discarded right after add operation is done. We create a simple API in `ShardMetaInfo` class to identify
21     this behavior, it is critical for better memory estimation.
22 
23     Returns:
24         Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]: compute cost, memory cost and forward inputs
25     """
26 
27     input_op_data = [arg for arg in args if arg.type != OperationDataType.OUTPUT]
28     output_op_data = next(filter(lambda arg: arg.type == OperationDataType.OUTPUT, args))
29 
30     # construct forward args for flop mapping
31     fwd_in_args = [opdata.data for opdata in input_op_data]
32     fwd_out_args = [output_op_data.data]
33 
34     # calculate cost
35 
36     # calculate compute cost
37     # NOTE: we set bwd_compute_cost two times of fwd_compute_cost in this case
38     fwd_compute_cost = flop_mapping[torch.ops.aten.add.Tensor](fwd_in_args, fwd_out_args)
39     bwd_compute_cost = fwd_compute_cost * 2
40     compute_cost = TrainCycleItem(fwd=fwd_compute_cost, bwd=bwd_compute_cost, total=fwd_compute_cost + bwd_compute_cost)
41 
42     # calculate memory cost
43     param_mem_cost = activation_size([arg.data for arg in input_op_data if arg.type == OperationDataType.PARAM])
44     fwd_mem_cost = MemoryCost(
45         activation=activation_size(output_op_data.data),
46         parameter=param_mem_cost,
47     )
48     bwd_mem_cost = MemoryCost(
49         activation=activation_size(fwd_in_args),
50         parameter=param_mem_cost,
51     )
52 
53     # total cost
54     total_mem_cost = MemoryCost(
55         activation=fwd_mem_cost.activation + bwd_mem_cost.activation,
56         parameter=fwd_mem_cost.parameter + bwd_mem_cost.parameter,
57     )
58 
59     memory_cost = TrainCycleItem(fwd=fwd_mem_cost, bwd=bwd_mem_cost, total=total_mem_cost)
60 
61     # store fwd_in, fwd_buffer, fwd_out
62     fwd_in = []
63     fwd_buffer = []
64     fwd_out = [torch.zeros_like(output_op_data.data, device="meta")]
65 
66     return compute_cost, memory_cost, fwd_in, fwd_buffer, fwd_out
67
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py b/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py
--- a/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py
+++ b/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py
@@ -4,9 +4,9 @@
 
 from colossalai._analyzer._subclasses.flop_tensor import flop_mapping
 from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size
+from colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP
 from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem
 
-from ..constants import BCAST_FUNC_OP
 from ..registry import meta_register
 
 __all__ = ["binary_elementwise_meta_info"]

{"golden_diff": "diff --git a/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py b/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py\n--- a/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py\n+++ b/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py\n@@ -4,9 +4,9 @@\n \n from colossalai._analyzer._subclasses.flop_tensor import flop_mapping\n from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size\n+from colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP\n from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem\n \n-from ..constants import BCAST_FUNC_OP\n from ..registry import meta_register\n \n __all__ = [\"binary_elementwise_meta_info\"]\n", "issue": "[BUG]: Wrong import in ColossalAuto's meta_registry/binary_elementwise_ops.py\n### \ud83d\udc1b Describe the bug\n\n# Problem description\r\n\r\nThe file `colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py` contains the following line: \r\n\r\n```python\r\nfrom ..constants import BCAST_FUNC_OP\r\n```\r\n\r\nHowever, the file `colossalai/auto_parallel/meta_profiler/constants.py` which this import refers to does not contain any `BCAST_FUNC_OP`. This leads to an `ImportError` when running ColossalAuto in release 0.3.3 and newer. \r\n\r\nThis constant can be found in the file `colossalai/auto_parallel/tensor_shard/constants.py`. The last commit to `colossalai/auto_parallel/meta_profiler/constants.py` (commit ID `079bf3cb`) removes the import of tensor_shard's `constants.py` from meta_profiler's `constants.py` (seemingly due to an automated refactoring).\r\n\r\n# Solution\r\n\r\nSince no other file in the `meta_registry` module uses constants from the `tensor_shard/constants.py` and to avoid automated removal of \"unused\" imports in the future, the import statement in question in above-mentioned `binary_elementwise_ops.py` could be changed to: \r\n\r\n```python\r\nfrom colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP\r\n```\n\n### Environment\n\n- Python 3.8\r\n- Torch 1.12.0\r\n- no CUDA\n", "before_files": [{"content": "from typing import List, Tuple\n\nimport torch\n\nfrom colossalai._analyzer._subclasses.flop_tensor import flop_mapping\nfrom colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size\nfrom colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem\n\nfrom ..constants import BCAST_FUNC_OP\nfrom ..registry import meta_register\n\n__all__ = [\"binary_elementwise_meta_info\"]\n\n\n@meta_register.register(BCAST_FUNC_OP)\ndef binary_elementwise_meta_info(*args, **kwargs) -> Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]:\n    \"\"\"Meta information generator for binary elementwise operations\n    NOTE: Some of the binary elementwise operations will discard the input activation after computation, as they\n    don't need those tensors for back propagation, for example, if there are two tensors being sent for `torch.add`,\n    they will be discarded right after add operation is done. We create a simple API in `ShardMetaInfo` class to identify\n    this behavior, it is critical for better memory estimation.\n\n    Returns:\n        Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]: compute cost, memory cost and forward inputs\n    \"\"\"\n\n    input_op_data = [arg for arg in args if arg.type != OperationDataType.OUTPUT]\n    output_op_data = next(filter(lambda arg: arg.type == OperationDataType.OUTPUT, args))\n\n    # construct forward args for flop mapping\n    fwd_in_args = [opdata.data for opdata in input_op_data]\n    fwd_out_args = [output_op_data.data]\n\n    # calculate cost\n\n    # calculate compute cost\n    # NOTE: we set bwd_compute_cost two times of fwd_compute_cost in this case\n    fwd_compute_cost = flop_mapping[torch.ops.aten.add.Tensor](fwd_in_args, fwd_out_args)\n    bwd_compute_cost = fwd_compute_cost * 2\n    compute_cost = TrainCycleItem(fwd=fwd_compute_cost, bwd=bwd_compute_cost, total=fwd_compute_cost + bwd_compute_cost)\n\n    # calculate memory cost\n    param_mem_cost = activation_size([arg.data for arg in input_op_data if arg.type == OperationDataType.PARAM])\n    fwd_mem_cost = MemoryCost(\n        activation=activation_size(output_op_data.data),\n        parameter=param_mem_cost,\n    )\n    bwd_mem_cost = MemoryCost(\n        activation=activation_size(fwd_in_args),\n        parameter=param_mem_cost,\n    )\n\n    # total cost\n    total_mem_cost = MemoryCost(\n        activation=fwd_mem_cost.activation + bwd_mem_cost.activation,\n        parameter=fwd_mem_cost.parameter + bwd_mem_cost.parameter,\n    )\n\n    memory_cost = TrainCycleItem(fwd=fwd_mem_cost, bwd=bwd_mem_cost, total=total_mem_cost)\n\n    # store fwd_in, fwd_buffer, fwd_out\n    fwd_in = []\n    fwd_buffer = []\n    fwd_out = [torch.zeros_like(output_op_data.data, device=\"meta\")]\n\n    return compute_cost, memory_cost, fwd_in, fwd_buffer, fwd_out\n", "path": "colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py"}], "after_files": [{"content": "from typing import List, Tuple\n\nimport torch\n\nfrom colossalai._analyzer._subclasses.flop_tensor import flop_mapping\nfrom colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size\nfrom colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP\nfrom colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem\n\nfrom ..registry import meta_register\n\n__all__ = [\"binary_elementwise_meta_info\"]\n\n\n@meta_register.register(BCAST_FUNC_OP)\ndef binary_elementwise_meta_info(*args, **kwargs) -> Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]:\n    \"\"\"Meta information generator for binary elementwise operations\n    NOTE: Some of the binary elementwise operations will discard the input activation after computation, as they\n    don't need those tensors for back propagation, for example, if there are two tensors being sent for `torch.add`,\n    they will be discarded right after add operation is done. We create a simple API in `ShardMetaInfo` class to identify\n    this behavior, it is critical for better memory estimation.\n\n    Returns:\n        Tuple[TrainCycleItem, TrainCycleItem, List[torch.Tensor]]: compute cost, memory cost and forward inputs\n    \"\"\"\n\n    input_op_data = [arg for arg in args if arg.type != OperationDataType.OUTPUT]\n    output_op_data = next(filter(lambda arg: arg.type == OperationDataType.OUTPUT, args))\n\n    # construct forward args for flop mapping\n    fwd_in_args = [opdata.data for opdata in input_op_data]\n    fwd_out_args = [output_op_data.data]\n\n    # calculate cost\n\n    # calculate compute cost\n    # NOTE: we set bwd_compute_cost two times of fwd_compute_cost in this case\n    fwd_compute_cost = flop_mapping[torch.ops.aten.add.Tensor](fwd_in_args, fwd_out_args)\n    bwd_compute_cost = fwd_compute_cost * 2\n    compute_cost = TrainCycleItem(fwd=fwd_compute_cost, bwd=bwd_compute_cost, total=fwd_compute_cost + bwd_compute_cost)\n\n    # calculate memory cost\n    param_mem_cost = activation_size([arg.data for arg in input_op_data if arg.type == OperationDataType.PARAM])\n    fwd_mem_cost = MemoryCost(\n        activation=activation_size(output_op_data.data),\n        parameter=param_mem_cost,\n    )\n    bwd_mem_cost = MemoryCost(\n        activation=activation_size(fwd_in_args),\n        parameter=param_mem_cost,\n    )\n\n    # total cost\n    total_mem_cost = MemoryCost(\n        activation=fwd_mem_cost.activation + bwd_mem_cost.activation,\n        parameter=fwd_mem_cost.parameter + bwd_mem_cost.parameter,\n    )\n\n    memory_cost = TrainCycleItem(fwd=fwd_mem_cost, bwd=bwd_mem_cost, total=total_mem_cost)\n\n    # store fwd_in, fwd_buffer, fwd_out\n    fwd_in = []\n    fwd_buffer = []\n    fwd_out = [torch.zeros_like(output_op_data.data, device=\"meta\")]\n\n    return compute_cost, memory_cost, fwd_in, fwd_buffer, fwd_out\n", "path": "colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py"}]}