We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Multiple dataset source for tag2label
It will be nice if I can choose not one input dir here https://github.com/catalyst-team/catalyst/blob/master/catalyst/contrib/scripts/tag2label.py

For example it can looks like:
`catalyst-contrib tag2label --in-dir=dataset1,dataset2`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `catalyst/contrib/scripts/tag2label.py`
Content:
```
1 import argparse
2 import json
3 import pandas as pd
4 
5 from catalyst.utils.data import create_dataset, create_dataframe, \
6     prepare_dataset_labeling, separate_tags
7 
8 
9 def prepare_df_from_dirs(in_dir, tag_column_name):
10     if not in_dir.endswith("/"):
11         in_dir = f"{in_dir}/"
12 
13     dataset = create_dataset(
14         f"{in_dir}/**", process_fn=lambda x: x.replace(f"{in_dir}", "")
15     )
16     df = create_dataframe(dataset, columns=[tag_column_name, "filepath"])
17 
18     return df
19 
20 
21 def build_args(parser):
22     parser.add_argument(
23         "--in-csv",
24         type=str,
25         default=None,
26         help="Path to data in `.csv`."
27     )
28     parser.add_argument(
29         "--in-dir",
30         type=str,
31         default=None,
32         help="Path to directory with dataset."
33     )
34 
35     parser.add_argument(
36         "--out-dataset",
37         type=str,
38         default=None,
39         required=True,
40         help="Path to output dataframe"
41     )
42     parser.add_argument(
43         "--out-labeling",
44         type=str,
45         default=None,
46         required=True,
47         help="Path to output JSON"
48     )
49 
50     parser.add_argument(
51         "--tag-column",
52         type=str,
53         default="tag",
54         help="Target column name"
55     )
56     parser.add_argument(
57         "--tag-delim",
58         type=str,
59         default=None,
60         help="Separator if you want to use several target columns"
61     )
62 
63     return parser
64 
65 
66 def parse_args():
67     parser = argparse.ArgumentParser()
68     build_args(parser)
69     args = parser.parse_args()
70     return args
71 
72 
73 def main(args, _=None):
74     if args.in_csv is not None:
75         df = pd.read_csv(args.in_csv)
76     elif args.in_dir is not None:
77         df = prepare_df_from_dirs(args.in_dir, args.tag_column)
78     else:
79         raise Exception
80 
81     if args.tag_delim is not None:
82         df = separate_tags(
83             df, tag_column=args.tag_column, tag_delim=args.tag_delim
84         )
85 
86     tag2lbl = prepare_dataset_labeling(df, args.tag_column)
87     print("Num classes: ", len(tag2lbl))
88 
89     with open(args.out_labeling, "w") as fout:
90         json.dump(tag2lbl, fout, indent=4)
91 
92     if args.out_dataset is not None:
93         df.to_csv(args.out_dataset, index=False)
94 
95 
96 if __name__ == "__main__":
97     args = parse_args()
98     main(args)
99
```
--- 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/catalyst/contrib/scripts/tag2label.py b/catalyst/contrib/scripts/tag2label.py
--- a/catalyst/contrib/scripts/tag2label.py
+++ b/catalyst/contrib/scripts/tag2label.py
@@ -6,15 +6,35 @@
     prepare_dataset_labeling, separate_tags
 
 
-def prepare_df_from_dirs(in_dir, tag_column_name):
-    if not in_dir.endswith("/"):
-        in_dir = f"{in_dir}/"
-
-    dataset = create_dataset(
-        f"{in_dir}/**", process_fn=lambda x: x.replace(f"{in_dir}", "")
-    )
-    df = create_dataframe(dataset, columns=[tag_column_name, "filepath"])
-
+def prepare_df_from_dirs(in_dirs, tag_column_name):
+    dfs = []
+    splitted_dirs = in_dirs.strip(',').split(',')
+
+    def process_fn(x):
+        if len(splitted_dirs) == 1:
+            # remove all in_dir part from path
+            return x.replace(f"{in_dir}", "")
+        else:
+            # leaves last part of in_dir path,
+            #  which identifies separate in_dir
+            return x.replace(
+                f"{in_dir}",
+                f"{in_dir.split('/')[-2]}/")
+
+    for in_dir in splitted_dirs:
+        if not in_dir.endswith("/"):
+            in_dir = f"{in_dir}/"
+
+        dataset = create_dataset(
+            f"{in_dir}/**",
+            process_fn=process_fn)
+
+        dfs.append(
+            create_dataframe(
+                dataset,
+                columns=[tag_column_name, "filepath"]))
+
+    df = pd.concat(dfs).reset_index(drop=True)
     return df
 
 
@@ -29,7 +49,8 @@
         "--in-dir",
         type=str,
         default=None,
-        help="Path to directory with dataset."
+        help="Path to directory with dataset"
+             "or paths separated by commas for several datasets"
     )
 
     parser.add_argument(

{"golden_diff": "diff --git a/catalyst/contrib/scripts/tag2label.py b/catalyst/contrib/scripts/tag2label.py\n--- a/catalyst/contrib/scripts/tag2label.py\n+++ b/catalyst/contrib/scripts/tag2label.py\n@@ -6,15 +6,35 @@\n     prepare_dataset_labeling, separate_tags\n \n \n-def prepare_df_from_dirs(in_dir, tag_column_name):\n-    if not in_dir.endswith(\"/\"):\n-        in_dir = f\"{in_dir}/\"\n-\n-    dataset = create_dataset(\n-        f\"{in_dir}/**\", process_fn=lambda x: x.replace(f\"{in_dir}\", \"\")\n-    )\n-    df = create_dataframe(dataset, columns=[tag_column_name, \"filepath\"])\n-\n+def prepare_df_from_dirs(in_dirs, tag_column_name):\n+    dfs = []\n+    splitted_dirs = in_dirs.strip(',').split(',')\n+\n+    def process_fn(x):\n+        if len(splitted_dirs) == 1:\n+            # remove all in_dir part from path\n+            return x.replace(f\"{in_dir}\", \"\")\n+        else:\n+            # leaves last part of in_dir path,\n+            #  which identifies separate in_dir\n+            return x.replace(\n+                f\"{in_dir}\",\n+                f\"{in_dir.split('/')[-2]}/\")\n+\n+    for in_dir in splitted_dirs:\n+        if not in_dir.endswith(\"/\"):\n+            in_dir = f\"{in_dir}/\"\n+\n+        dataset = create_dataset(\n+            f\"{in_dir}/**\",\n+            process_fn=process_fn)\n+\n+        dfs.append(\n+            create_dataframe(\n+                dataset,\n+                columns=[tag_column_name, \"filepath\"]))\n+\n+    df = pd.concat(dfs).reset_index(drop=True)\n     return df\n \n \n@@ -29,7 +49,8 @@\n         \"--in-dir\",\n         type=str,\n         default=None,\n-        help=\"Path to directory with dataset.\"\n+        help=\"Path to directory with dataset\"\n+             \"or paths separated by commas for several datasets\"\n     )\n \n     parser.add_argument(\n", "issue": "Multiple dataset source for tag2label\nIt will be nice if I can choose not one input dir here https://github.com/catalyst-team/catalyst/blob/master/catalyst/contrib/scripts/tag2label.py\r\n\r\nFor example it can looks like:\r\n`catalyst-contrib tag2label --in-dir=dataset1,dataset2`\n", "before_files": [{"content": "import argparse\nimport json\nimport pandas as pd\n\nfrom catalyst.utils.data import create_dataset, create_dataframe, \\\n    prepare_dataset_labeling, separate_tags\n\n\ndef prepare_df_from_dirs(in_dir, tag_column_name):\n    if not in_dir.endswith(\"/\"):\n        in_dir = f\"{in_dir}/\"\n\n    dataset = create_dataset(\n        f\"{in_dir}/**\", process_fn=lambda x: x.replace(f\"{in_dir}\", \"\")\n    )\n    df = create_dataframe(dataset, columns=[tag_column_name, \"filepath\"])\n\n    return df\n\n\ndef build_args(parser):\n    parser.add_argument(\n        \"--in-csv\",\n        type=str,\n        default=None,\n        help=\"Path to data in `.csv`.\"\n    )\n    parser.add_argument(\n        \"--in-dir\",\n        type=str,\n        default=None,\n        help=\"Path to directory with dataset.\"\n    )\n\n    parser.add_argument(\n        \"--out-dataset\",\n        type=str,\n        default=None,\n        required=True,\n        help=\"Path to output dataframe\"\n    )\n    parser.add_argument(\n        \"--out-labeling\",\n        type=str,\n        default=None,\n        required=True,\n        help=\"Path to output JSON\"\n    )\n\n    parser.add_argument(\n        \"--tag-column\",\n        type=str,\n        default=\"tag\",\n        help=\"Target column name\"\n    )\n    parser.add_argument(\n        \"--tag-delim\",\n        type=str,\n        default=None,\n        help=\"Separator if you want to use several target columns\"\n    )\n\n    return parser\n\n\ndef parse_args():\n    parser = argparse.ArgumentParser()\n    build_args(parser)\n    args = parser.parse_args()\n    return args\n\n\ndef main(args, _=None):\n    if args.in_csv is not None:\n        df = pd.read_csv(args.in_csv)\n    elif args.in_dir is not None:\n        df = prepare_df_from_dirs(args.in_dir, args.tag_column)\n    else:\n        raise Exception\n\n    if args.tag_delim is not None:\n        df = separate_tags(\n            df, tag_column=args.tag_column, tag_delim=args.tag_delim\n        )\n\n    tag2lbl = prepare_dataset_labeling(df, args.tag_column)\n    print(\"Num classes: \", len(tag2lbl))\n\n    with open(args.out_labeling, \"w\") as fout:\n        json.dump(tag2lbl, fout, indent=4)\n\n    if args.out_dataset is not None:\n        df.to_csv(args.out_dataset, index=False)\n\n\nif __name__ == \"__main__\":\n    args = parse_args()\n    main(args)\n", "path": "catalyst/contrib/scripts/tag2label.py"}], "after_files": [{"content": "import argparse\nimport json\nimport pandas as pd\n\nfrom catalyst.utils.data import create_dataset, create_dataframe, \\\n    prepare_dataset_labeling, separate_tags\n\n\ndef prepare_df_from_dirs(in_dirs, tag_column_name):\n    dfs = []\n    splitted_dirs = in_dirs.strip(',').split(',')\n\n    def process_fn(x):\n        if len(splitted_dirs) == 1:\n            # remove all in_dir part from path\n            return x.replace(f\"{in_dir}\", \"\")\n        else:\n            # leaves last part of in_dir path,\n            #  which identifies separate in_dir\n            return x.replace(\n                f\"{in_dir}\",\n                f\"{in_dir.split('/')[-2]}/\")\n\n    for in_dir in splitted_dirs:\n        if not in_dir.endswith(\"/\"):\n            in_dir = f\"{in_dir}/\"\n\n        dataset = create_dataset(\n            f\"{in_dir}/**\",\n            process_fn=process_fn)\n\n        dfs.append(\n            create_dataframe(\n                dataset,\n                columns=[tag_column_name, \"filepath\"]))\n\n    df = pd.concat(dfs).reset_index(drop=True)\n    return df\n\n\ndef build_args(parser):\n    parser.add_argument(\n        \"--in-csv\",\n        type=str,\n        default=None,\n        help=\"Path to data in `.csv`.\"\n    )\n    parser.add_argument(\n        \"--in-dir\",\n        type=str,\n        default=None,\n        help=\"Path to directory with dataset\"\n             \"or paths separated by commas for several datasets\"\n    )\n\n    parser.add_argument(\n        \"--out-dataset\",\n        type=str,\n        default=None,\n        required=True,\n        help=\"Path to output dataframe\"\n    )\n    parser.add_argument(\n        \"--out-labeling\",\n        type=str,\n        default=None,\n        required=True,\n        help=\"Path to output JSON\"\n    )\n\n    parser.add_argument(\n        \"--tag-column\",\n        type=str,\n        default=\"tag\",\n        help=\"Target column name\"\n    )\n    parser.add_argument(\n        \"--tag-delim\",\n        type=str,\n        default=None,\n        help=\"Separator if you want to use several target columns\"\n    )\n\n    return parser\n\n\ndef parse_args():\n    parser = argparse.ArgumentParser()\n    build_args(parser)\n    args = parser.parse_args()\n    return args\n\n\ndef main(args, _=None):\n    if args.in_csv is not None:\n        df = pd.read_csv(args.in_csv)\n    elif args.in_dir is not None:\n        df = prepare_df_from_dirs(args.in_dir, args.tag_column)\n    else:\n        raise Exception\n\n    if args.tag_delim is not None:\n        df = separate_tags(\n            df, tag_column=args.tag_column, tag_delim=args.tag_delim\n        )\n\n    tag2lbl = prepare_dataset_labeling(df, args.tag_column)\n    print(\"Num classes: \", len(tag2lbl))\n\n    with open(args.out_labeling, \"w\") as fout:\n        json.dump(tag2lbl, fout, indent=4)\n\n    if args.out_dataset is not None:\n        df.to_csv(args.out_dataset, index=False)\n\n\nif __name__ == \"__main__\":\n    args = parse_args()\n    main(args)\n", "path": "catalyst/contrib/scripts/tag2label.py"}]}