We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] pydantic DeepSpeedConfigModel has no validator for <class:object>
**Describe the bug**
During ```from deepspeed.inference.config import DtypeEnum```, got error 
```
 File "pydantic/main.py", line 299, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/fields.py", line 411, in pydantic.fields.ModelField.infer
  File "pydantic/fields.py", line 342, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 456, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 670, in pydantic.fields.ModelField.populate_validators
  File "pydantic/validators.py", line 715, in find_validators
RuntimeError: no validator found for <class 'object'>, see `arbitrary_types_allowed` in Config
```

**To Reproduce**
Steps to reproduce the behavior:
1. Simple inference script to reproduce ```from deepspeed.inference.config import DtypeEnum```
2. pydantic 1.8.2, deepspeed 0.8.0+384f17b


**Expected behavior**
successful import with no error

**ds_report output**
cannot produce due to the same import error

**System info (please complete the following information):**
 - OS: Red Hat Enterprise Linux Server 7.9 (Maipo)
 - GPU count and types: one machine with 8 A100s, three machines with 8 A100s each
 - Hugging Face Transformers 4.19.2, no accelerate
 - Python version 3.8.13


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `deepspeed/runtime/config_utils.py`
Content:
```
1 """
2 Copyright (c) Microsoft Corporation
3 Licensed under the MIT license.
4 """
5 """
6 Collection of DeepSpeed configuration utilities
7 """
8 import json
9 import collections
10 import collections.abc
11 from functools import reduce
12 from pydantic import BaseModel
13 from deepspeed.utils import logger
14 
15 
16 class DeepSpeedConfigModel(BaseModel):
17     """
18     This class should be used as a base for all DeepSpeed configs. It extends
19     pydantic.BaseModel to allow for deprecated fields. To enable this feature,
20     add deprecated=True to pydantic.Field:
21 
22     my_dep_field: int = Field(0, deprecated=True)
23 
24     Deprecated Field kwargs:
25     - deprecated: [True|False], default False
26         Enables / Disables deprecated fields
27     - new_param: str, default ""
28         Name of the field replacing the deprecated field
29     - set_new_param: [True|False], default True
30         If new_param is provided, enables setting the value of that param with
31         deprecated field value
32     - new_param_fn: callable, default (lambda x: x)
33         If new_param is provided and set_new_param is True, this function will
34         modify the value of the deprecated field before placing that value in
35         the new_param field
36 
37     Example:
38         my_new_field is replacing a deprecated my_old_field. The expected type
39         for my_new_field is int while the expected type for my_old_field is
40         str. We want to maintain backward compatibility with our configs, so we
41         define the fields with:
42 
43         class MyExampleConfig(DeepSpeedConfigModel):
44             my_new_field: int = 0
45             my_old_field: str = Field('0',
46                                       deprecated=True,
47                                       new_param='my_new_field',
48                                       new_param_fn=(lambda x: int(x)))
49     """
50     def __init__(self, strict=False, **data):
51         if (
52                 not strict
53         ):  # This is temporary until we refactor all DS configs, allows HF to load models
54             data = {k: v for k, v in data.items() if v != "auto"}
55         super().__init__(**data)
56         self._deprecated_fields_check(self)
57 
58     def _process_deprecated_field(self, pydantic_config, field):
59         # Get information about the deprecated field
60         fields_set = pydantic_config.__fields_set__
61         dep_param = field.name
62         kwargs = field.field_info.extra
63         new_param_fn = kwargs.get("new_param_fn", lambda x: x)
64         param_value = new_param_fn(getattr(pydantic_config, dep_param))
65         new_param = kwargs.get("new_param", "")
66         if dep_param in fields_set:
67             logger.warning(f"Config parameter {dep_param} is deprecated" +
68                            (f" use {new_param} instead" if new_param else ""))
69             # Check if there is a new param and if it should be set with a value
70             if new_param and kwargs.get("set_new_param", True):
71                 # Remove the deprecate field if there is a replacing field
72                 try:
73                     delattr(pydantic_config, dep_param)
74                 except Exception as e:
75                     logger.error(f"Tried removing deprecated '{dep_param}' from config")
76                     raise e
77 
78                 # Set new param value
79                 new_param_nested = new_param.split(".")
80                 if len(new_param_nested) > 1:
81                     # If the new param exists in a subconfig, we need to get
82                     # the fields set for that subconfig
83                     pydantic_config = reduce(getattr,
84                                              new_param_nested[:-1],
85                                              pydantic_config)
86                     fields_set = pydantic_config.__fields_set__
87                 new_param_name = new_param_nested[-1]
88                 assert (
89                     new_param_name not in fields_set
90                 ), f"Cannot provide deprecated parameter '{dep_param}' and replacing parameter '{new_param}' together"
91                 # A custom function for converting the old param value to new param value can be provided
92                 try:
93                     setattr(pydantic_config, new_param_name, param_value)
94                 except Exception as e:
95                     logger.error(
96                         f"Tried setting value for '{new_param}' with value from deprecated '{dep_param}'"
97                     )
98                     raise e
99 
100     def _deprecated_fields_check(self, pydantic_config):
101         fields = pydantic_config.__fields__
102         for field in fields.values():
103             if field.field_info.extra.get("deprecated", False):
104                 self._process_deprecated_field(pydantic_config, field)
105 
106     class Config:
107         validate_all = True
108         validate_assignment = True
109         use_enum_values = True
110         allow_population_by_field_name = True
111         extra = "forbid"
112 
113 
114 class pp_int(int):
115     """
116     A wrapper for integers that will return a custom string or comma-formatted
117     string of the integer. For example, print(pp_int(1e5)) will return
118     "10,000". This is useful mainly for auto-generated documentation purposes.
119     """
120     def __new__(cls, val, custom_print_str=None):
121         inst = super().__new__(cls, val)
122         inst.custom_print_str = custom_print_str
123         return inst
124 
125     def __repr__(self):
126         if self.custom_print_str:
127             return self.custom_print_str
128         return f"{self.real:,}"
129 
130 
131 # adapted from https://stackoverflow.com/a/50701137/9201239
132 class ScientificNotationEncoder(json.JSONEncoder):
133     """
134     This class overrides ``json.dumps`` default formatter.
135 
136     This version keeps everything as normal except formats numbers bigger than 1e3 using scientific notation.
137 
138     Just pass ``cls=ScientificNotationEncoder`` to ``json.dumps`` to activate it
139 
140     """
141     def iterencode(self, o, _one_shot=False, level=0):
142         indent = self.indent if self.indent is not None else 4
143         prefix_close = " " * level * indent
144         level += 1
145         prefix = " " * level * indent
146         if isinstance(o, bool):
147             return "true" if o else "false"
148         elif isinstance(o, float) or isinstance(o, int):
149             if o > 1e3:
150                 return f"{o:e}"
151             else:
152                 return f"{o}"
153         elif isinstance(o, collections.abc.Mapping):
154             x = [
155                 f'\n{prefix}"{k}": {self.iterencode(v, level=level)}' for k,
156                 v in o.items()
157             ]
158             return "{" + ", ".join(x) + f"\n{prefix_close}" + "}"
159         elif isinstance(o, collections.abc.Sequence) and not isinstance(o, str):
160             return f"[{ f', '.join(map(self.iterencode, o)) }]"
161         return "\n, ".join(super().iterencode(o, _one_shot))
162 
163 
164 class DeepSpeedConfigObject(object):
165     """
166     For json serialization
167     """
168     def repr(self):
169         return self.__dict__
170 
171     def __repr__(self):
172         return json.dumps(
173             self.__dict__,
174             sort_keys=True,
175             indent=4,
176             cls=ScientificNotationEncoder,
177         )
178 
179 
180 def get_scalar_param(param_dict, param_name, param_default_value):
181     return param_dict.get(param_name, param_default_value)
182 
183 
184 def get_list_param(param_dict, param_name, param_default_value):
185     return param_dict.get(param_name, param_default_value)
186 
187 
188 def get_dict_param(param_dict, param_name, param_default_value):
189     return param_dict.get(param_name, param_default_value)
190 
191 
192 def dict_raise_error_on_duplicate_keys(ordered_pairs):
193     """Reject duplicate keys."""
194     d = dict((k, v) for k, v in ordered_pairs)
195     if len(d) != len(ordered_pairs):
196         counter = collections.Counter([pair[0] for pair in ordered_pairs])
197         keys = [key for key, value in counter.items() if value > 1]
198         raise ValueError("Duplicate keys in DeepSpeed config: {}".format(keys))
199     return d
200
```
--- 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/deepspeed/runtime/config_utils.py b/deepspeed/runtime/config_utils.py
--- a/deepspeed/runtime/config_utils.py
+++ b/deepspeed/runtime/config_utils.py
@@ -109,6 +109,7 @@
         use_enum_values = True
         allow_population_by_field_name = True
         extra = "forbid"
+        arbitrary_types_allowed = True
 
 
 class pp_int(int):

{"golden_diff": "diff --git a/deepspeed/runtime/config_utils.py b/deepspeed/runtime/config_utils.py\n--- a/deepspeed/runtime/config_utils.py\n+++ b/deepspeed/runtime/config_utils.py\n@@ -109,6 +109,7 @@\n         use_enum_values = True\n         allow_population_by_field_name = True\n         extra = \"forbid\"\n+        arbitrary_types_allowed = True\n \n \n class pp_int(int):\n", "issue": "[BUG] pydantic DeepSpeedConfigModel has no validator for <class:object>\n**Describe the bug**\r\nDuring ```from deepspeed.inference.config import DtypeEnum```, got error \r\n```\r\n File \"pydantic/main.py\", line 299, in pydantic.main.ModelMetaclass.__new__\r\n  File \"pydantic/fields.py\", line 411, in pydantic.fields.ModelField.infer\r\n  File \"pydantic/fields.py\", line 342, in pydantic.fields.ModelField.__init__\r\n  File \"pydantic/fields.py\", line 456, in pydantic.fields.ModelField.prepare\r\n  File \"pydantic/fields.py\", line 670, in pydantic.fields.ModelField.populate_validators\r\n  File \"pydantic/validators.py\", line 715, in find_validators\r\nRuntimeError: no validator found for <class 'object'>, see `arbitrary_types_allowed` in Config\r\n```\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Simple inference script to reproduce ```from deepspeed.inference.config import DtypeEnum```\r\n2. pydantic 1.8.2, deepspeed 0.8.0+384f17b\r\n\r\n\r\n**Expected behavior**\r\nsuccessful import with no error\r\n\r\n**ds_report output**\r\ncannot produce due to the same import error\r\n\r\n**System info (please complete the following information):**\r\n - OS: Red Hat Enterprise Linux Server 7.9 (Maipo)\r\n - GPU count and types: one machine with 8 A100s, three machines with 8 A100s each\r\n - Hugging Face Transformers 4.19.2, no accelerate\r\n - Python version 3.8.13\r\n\n", "before_files": [{"content": "\"\"\"\nCopyright (c) Microsoft Corporation\nLicensed under the MIT license.\n\"\"\"\n\"\"\"\nCollection of DeepSpeed configuration utilities\n\"\"\"\nimport json\nimport collections\nimport collections.abc\nfrom functools import reduce\nfrom pydantic import BaseModel\nfrom deepspeed.utils import logger\n\n\nclass DeepSpeedConfigModel(BaseModel):\n    \"\"\"\n    This class should be used as a base for all DeepSpeed configs. It extends\n    pydantic.BaseModel to allow for deprecated fields. To enable this feature,\n    add deprecated=True to pydantic.Field:\n\n    my_dep_field: int = Field(0, deprecated=True)\n\n    Deprecated Field kwargs:\n    - deprecated: [True|False], default False\n        Enables / Disables deprecated fields\n    - new_param: str, default \"\"\n        Name of the field replacing the deprecated field\n    - set_new_param: [True|False], default True\n        If new_param is provided, enables setting the value of that param with\n        deprecated field value\n    - new_param_fn: callable, default (lambda x: x)\n        If new_param is provided and set_new_param is True, this function will\n        modify the value of the deprecated field before placing that value in\n        the new_param field\n\n    Example:\n        my_new_field is replacing a deprecated my_old_field. The expected type\n        for my_new_field is int while the expected type for my_old_field is\n        str. We want to maintain backward compatibility with our configs, so we\n        define the fields with:\n\n        class MyExampleConfig(DeepSpeedConfigModel):\n            my_new_field: int = 0\n            my_old_field: str = Field('0',\n                                      deprecated=True,\n                                      new_param='my_new_field',\n                                      new_param_fn=(lambda x: int(x)))\n    \"\"\"\n    def __init__(self, strict=False, **data):\n        if (\n                not strict\n        ):  # This is temporary until we refactor all DS configs, allows HF to load models\n            data = {k: v for k, v in data.items() if v != \"auto\"}\n        super().__init__(**data)\n        self._deprecated_fields_check(self)\n\n    def _process_deprecated_field(self, pydantic_config, field):\n        # Get information about the deprecated field\n        fields_set = pydantic_config.__fields_set__\n        dep_param = field.name\n        kwargs = field.field_info.extra\n        new_param_fn = kwargs.get(\"new_param_fn\", lambda x: x)\n        param_value = new_param_fn(getattr(pydantic_config, dep_param))\n        new_param = kwargs.get(\"new_param\", \"\")\n        if dep_param in fields_set:\n            logger.warning(f\"Config parameter {dep_param} is deprecated\" +\n                           (f\" use {new_param} instead\" if new_param else \"\"))\n            # Check if there is a new param and if it should be set with a value\n            if new_param and kwargs.get(\"set_new_param\", True):\n                # Remove the deprecate field if there is a replacing field\n                try:\n                    delattr(pydantic_config, dep_param)\n                except Exception as e:\n                    logger.error(f\"Tried removing deprecated '{dep_param}' from config\")\n                    raise e\n\n                # Set new param value\n                new_param_nested = new_param.split(\".\")\n                if len(new_param_nested) > 1:\n                    # If the new param exists in a subconfig, we need to get\n                    # the fields set for that subconfig\n                    pydantic_config = reduce(getattr,\n                                             new_param_nested[:-1],\n                                             pydantic_config)\n                    fields_set = pydantic_config.__fields_set__\n                new_param_name = new_param_nested[-1]\n                assert (\n                    new_param_name not in fields_set\n                ), f\"Cannot provide deprecated parameter '{dep_param}' and replacing parameter '{new_param}' together\"\n                # A custom function for converting the old param value to new param value can be provided\n                try:\n                    setattr(pydantic_config, new_param_name, param_value)\n                except Exception as e:\n                    logger.error(\n                        f\"Tried setting value for '{new_param}' with value from deprecated '{dep_param}'\"\n                    )\n                    raise e\n\n    def _deprecated_fields_check(self, pydantic_config):\n        fields = pydantic_config.__fields__\n        for field in fields.values():\n            if field.field_info.extra.get(\"deprecated\", False):\n                self._process_deprecated_field(pydantic_config, field)\n\n    class Config:\n        validate_all = True\n        validate_assignment = True\n        use_enum_values = True\n        allow_population_by_field_name = True\n        extra = \"forbid\"\n\n\nclass pp_int(int):\n    \"\"\"\n    A wrapper for integers that will return a custom string or comma-formatted\n    string of the integer. For example, print(pp_int(1e5)) will return\n    \"10,000\". This is useful mainly for auto-generated documentation purposes.\n    \"\"\"\n    def __new__(cls, val, custom_print_str=None):\n        inst = super().__new__(cls, val)\n        inst.custom_print_str = custom_print_str\n        return inst\n\n    def __repr__(self):\n        if self.custom_print_str:\n            return self.custom_print_str\n        return f\"{self.real:,}\"\n\n\n# adapted from https://stackoverflow.com/a/50701137/9201239\nclass ScientificNotationEncoder(json.JSONEncoder):\n    \"\"\"\n    This class overrides ``json.dumps`` default formatter.\n\n    This version keeps everything as normal except formats numbers bigger than 1e3 using scientific notation.\n\n    Just pass ``cls=ScientificNotationEncoder`` to ``json.dumps`` to activate it\n\n    \"\"\"\n    def iterencode(self, o, _one_shot=False, level=0):\n        indent = self.indent if self.indent is not None else 4\n        prefix_close = \" \" * level * indent\n        level += 1\n        prefix = \" \" * level * indent\n        if isinstance(o, bool):\n            return \"true\" if o else \"false\"\n        elif isinstance(o, float) or isinstance(o, int):\n            if o > 1e3:\n                return f\"{o:e}\"\n            else:\n                return f\"{o}\"\n        elif isinstance(o, collections.abc.Mapping):\n            x = [\n                f'\\n{prefix}\"{k}\": {self.iterencode(v, level=level)}' for k,\n                v in o.items()\n            ]\n            return \"{\" + \", \".join(x) + f\"\\n{prefix_close}\" + \"}\"\n        elif isinstance(o, collections.abc.Sequence) and not isinstance(o, str):\n            return f\"[{ f', '.join(map(self.iterencode, o)) }]\"\n        return \"\\n, \".join(super().iterencode(o, _one_shot))\n\n\nclass DeepSpeedConfigObject(object):\n    \"\"\"\n    For json serialization\n    \"\"\"\n    def repr(self):\n        return self.__dict__\n\n    def __repr__(self):\n        return json.dumps(\n            self.__dict__,\n            sort_keys=True,\n            indent=4,\n            cls=ScientificNotationEncoder,\n        )\n\n\ndef get_scalar_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef get_list_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef get_dict_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef dict_raise_error_on_duplicate_keys(ordered_pairs):\n    \"\"\"Reject duplicate keys.\"\"\"\n    d = dict((k, v) for k, v in ordered_pairs)\n    if len(d) != len(ordered_pairs):\n        counter = collections.Counter([pair[0] for pair in ordered_pairs])\n        keys = [key for key, value in counter.items() if value > 1]\n        raise ValueError(\"Duplicate keys in DeepSpeed config: {}\".format(keys))\n    return d\n", "path": "deepspeed/runtime/config_utils.py"}], "after_files": [{"content": "\"\"\"\nCopyright (c) Microsoft Corporation\nLicensed under the MIT license.\n\"\"\"\n\"\"\"\nCollection of DeepSpeed configuration utilities\n\"\"\"\nimport json\nimport collections\nimport collections.abc\nfrom functools import reduce\nfrom pydantic import BaseModel\nfrom deepspeed.utils import logger\n\n\nclass DeepSpeedConfigModel(BaseModel):\n    \"\"\"\n    This class should be used as a base for all DeepSpeed configs. It extends\n    pydantic.BaseModel to allow for deprecated fields. To enable this feature,\n    add deprecated=True to pydantic.Field:\n\n    my_dep_field: int = Field(0, deprecated=True)\n\n    Deprecated Field kwargs:\n    - deprecated: [True|False], default False\n        Enables / Disables deprecated fields\n    - new_param: str, default \"\"\n        Name of the field replacing the deprecated field\n    - set_new_param: [True|False], default True\n        If new_param is provided, enables setting the value of that param with\n        deprecated field value\n    - new_param_fn: callable, default (lambda x: x)\n        If new_param is provided and set_new_param is True, this function will\n        modify the value of the deprecated field before placing that value in\n        the new_param field\n\n    Example:\n        my_new_field is replacing a deprecated my_old_field. The expected type\n        for my_new_field is int while the expected type for my_old_field is\n        str. We want to maintain backward compatibility with our configs, so we\n        define the fields with:\n\n        class MyExampleConfig(DeepSpeedConfigModel):\n            my_new_field: int = 0\n            my_old_field: str = Field('0',\n                                      deprecated=True,\n                                      new_param='my_new_field',\n                                      new_param_fn=(lambda x: int(x)))\n    \"\"\"\n    def __init__(self, strict=False, **data):\n        if (\n                not strict\n        ):  # This is temporary until we refactor all DS configs, allows HF to load models\n            data = {k: v for k, v in data.items() if v != \"auto\"}\n        super().__init__(**data)\n        self._deprecated_fields_check(self)\n\n    def _process_deprecated_field(self, pydantic_config, field):\n        # Get information about the deprecated field\n        fields_set = pydantic_config.__fields_set__\n        dep_param = field.name\n        kwargs = field.field_info.extra\n        new_param_fn = kwargs.get(\"new_param_fn\", lambda x: x)\n        param_value = new_param_fn(getattr(pydantic_config, dep_param))\n        new_param = kwargs.get(\"new_param\", \"\")\n        if dep_param in fields_set:\n            logger.warning(f\"Config parameter {dep_param} is deprecated\" +\n                           (f\" use {new_param} instead\" if new_param else \"\"))\n            # Check if there is a new param and if it should be set with a value\n            if new_param and kwargs.get(\"set_new_param\", True):\n                # Remove the deprecate field if there is a replacing field\n                try:\n                    delattr(pydantic_config, dep_param)\n                except Exception as e:\n                    logger.error(f\"Tried removing deprecated '{dep_param}' from config\")\n                    raise e\n\n                # Set new param value\n                new_param_nested = new_param.split(\".\")\n                if len(new_param_nested) > 1:\n                    # If the new param exists in a subconfig, we need to get\n                    # the fields set for that subconfig\n                    pydantic_config = reduce(getattr,\n                                             new_param_nested[:-1],\n                                             pydantic_config)\n                    fields_set = pydantic_config.__fields_set__\n                new_param_name = new_param_nested[-1]\n                assert (\n                    new_param_name not in fields_set\n                ), f\"Cannot provide deprecated parameter '{dep_param}' and replacing parameter '{new_param}' together\"\n                # A custom function for converting the old param value to new param value can be provided\n                try:\n                    setattr(pydantic_config, new_param_name, param_value)\n                except Exception as e:\n                    logger.error(\n                        f\"Tried setting value for '{new_param}' with value from deprecated '{dep_param}'\"\n                    )\n                    raise e\n\n    def _deprecated_fields_check(self, pydantic_config):\n        fields = pydantic_config.__fields__\n        for field in fields.values():\n            if field.field_info.extra.get(\"deprecated\", False):\n                self._process_deprecated_field(pydantic_config, field)\n\n    class Config:\n        validate_all = True\n        validate_assignment = True\n        use_enum_values = True\n        allow_population_by_field_name = True\n        extra = \"forbid\"\n        arbitrary_types_allowed = True\n\n\nclass pp_int(int):\n    \"\"\"\n    A wrapper for integers that will return a custom string or comma-formatted\n    string of the integer. For example, print(pp_int(1e5)) will return\n    \"10,000\". This is useful mainly for auto-generated documentation purposes.\n    \"\"\"\n    def __new__(cls, val, custom_print_str=None):\n        inst = super().__new__(cls, val)\n        inst.custom_print_str = custom_print_str\n        return inst\n\n    def __repr__(self):\n        if self.custom_print_str:\n            return self.custom_print_str\n        return f\"{self.real:,}\"\n\n\n# adapted from https://stackoverflow.com/a/50701137/9201239\nclass ScientificNotationEncoder(json.JSONEncoder):\n    \"\"\"\n    This class overrides ``json.dumps`` default formatter.\n\n    This version keeps everything as normal except formats numbers bigger than 1e3 using scientific notation.\n\n    Just pass ``cls=ScientificNotationEncoder`` to ``json.dumps`` to activate it\n\n    \"\"\"\n    def iterencode(self, o, _one_shot=False, level=0):\n        indent = self.indent if self.indent is not None else 4\n        prefix_close = \" \" * level * indent\n        level += 1\n        prefix = \" \" * level * indent\n        if isinstance(o, bool):\n            return \"true\" if o else \"false\"\n        elif isinstance(o, float) or isinstance(o, int):\n            if o > 1e3:\n                return f\"{o:e}\"\n            else:\n                return f\"{o}\"\n        elif isinstance(o, collections.abc.Mapping):\n            x = [\n                f'\\n{prefix}\"{k}\": {self.iterencode(v, level=level)}' for k,\n                v in o.items()\n            ]\n            return \"{\" + \", \".join(x) + f\"\\n{prefix_close}\" + \"}\"\n        elif isinstance(o, collections.abc.Sequence) and not isinstance(o, str):\n            return f\"[{ f', '.join(map(self.iterencode, o)) }]\"\n        return \"\\n, \".join(super().iterencode(o, _one_shot))\n\n\nclass DeepSpeedConfigObject(object):\n    \"\"\"\n    For json serialization\n    \"\"\"\n    def repr(self):\n        return self.__dict__\n\n    def __repr__(self):\n        return json.dumps(\n            self.__dict__,\n            sort_keys=True,\n            indent=4,\n            cls=ScientificNotationEncoder,\n        )\n\n\ndef get_scalar_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef get_list_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef get_dict_param(param_dict, param_name, param_default_value):\n    return param_dict.get(param_name, param_default_value)\n\n\ndef dict_raise_error_on_duplicate_keys(ordered_pairs):\n    \"\"\"Reject duplicate keys.\"\"\"\n    d = dict((k, v) for k, v in ordered_pairs)\n    if len(d) != len(ordered_pairs):\n        counter = collections.Counter([pair[0] for pair in ordered_pairs])\n        keys = [key for key, value in counter.items() if value > 1]\n        raise ValueError(\"Duplicate keys in DeepSpeed config: {}\".format(keys))\n    return d\n", "path": "deepspeed/runtime/config_utils.py"}]}