def get_object(obj, predefined_objects=None, default_object=None, kwargs=None):
args = ()<EOL>kwargs = dict() if kwargs is None else kwargs<EOL>if isinstance(obj, str) and os.path.isfile(obj):<EOL><INDENT>with open(obj, '<STR_LIT:r>') as fp:<EOL><INDENT>obj = json.load(fp=fp)<EOL><DEDENT><DEDENT>if isinstance(obj, dict):<EOL><INDENT>kwargs.update(obj)<EOL>obj = kwargs.pop('<STR_LIT:type>', None)<EOL><DEDENT>if predefined_objects is not None and obj in predefined_objects:<EOL><INDENT>obj = predefined_objects[obj]<EOL><DEDENT>elif isinstance(obj, str):<EOL><INDENT>if obj.find('<STR_LIT:.>') != -<NUM_LIT:1>:<EOL><INDENT>module_name, function_name = obj.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL>module = importlib.import_module(module_name)<EOL>obj = getattr(module, function_name)<EOL><DEDENT>else:<EOL><INDENT>raise TensorForceError("<STR_LIT>".format(<EOL>obj,<EOL>list(predefined_objects or ())<EOL>))<EOL><DEDENT><DEDENT>elif callable(obj):<EOL><INDENT>pass<EOL><DEDENT>elif default_object is not None:<EOL><INDENT>args = (obj,)<EOL>obj = default_object<EOL><DEDENT>else:<EOL><INDENT>return obj<EOL><DEDENT>return obj(*args, **kwargs)<EOL>
Utility method to map some kind of object specification to its content,
e.g. optimizer or baseline specifications to the respective classes.

Args:
    obj: A specification dict (value for key 'type' optionally specifies
            the object, options as follows), a module path (e.g.,
            my_module.MyClass), a key in predefined_objects, or a callable
            (e.g., the class type object).
    predefined_objects: Dict containing predefined set of objects,
            accessible via their key
    default_object: Default object is no other is specified
    kwargs: Arguments for object creation

Returns: The retrieved object