Upload utils.py with huggingface_hub
Browse files
utils.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
from queue import Queue
|
2 |
from typing import Any, Dict
|
3 |
|
4 |
|
@@ -7,11 +6,13 @@ class Singleton(type):
|
|
7 |
|
8 |
def __call__(cls, *args, **kwargs):
|
9 |
if cls not in cls._instances:
|
10 |
-
cls._instances[cls] = super(
|
11 |
return cls._instances[cls]
|
12 |
|
13 |
|
14 |
-
def flatten_dict(
|
|
|
|
|
15 |
items = []
|
16 |
for k, v in d.items():
|
17 |
new_key = parent_key + sep + k if parent_key else k
|
|
|
|
|
1 |
from typing import Any, Dict
|
2 |
|
3 |
|
|
|
6 |
|
7 |
def __call__(cls, *args, **kwargs):
|
8 |
if cls not in cls._instances:
|
9 |
+
cls._instances[cls] = super().__call__(*args, **kwargs)
|
10 |
return cls._instances[cls]
|
11 |
|
12 |
|
13 |
+
def flatten_dict(
|
14 |
+
d: Dict[str, Any], parent_key: str = "", sep: str = "_"
|
15 |
+
) -> Dict[str, Any]:
|
16 |
items = []
|
17 |
for k, v in d.items():
|
18 |
new_key = parent_key + sep + k if parent_key else k
|