From 2bff09c6ffe630d072589a4061f393b47edfadde Mon Sep 17 00:00:00 2001 From: Deeptendu Santra <55111154+Dsantra92@users.noreply.github.com> Date: Fri, 9 Feb 2024 23:02:13 -0800 Subject: [PATCH] add __reduce__ method to IvyGlobalProps (#28234) Co-authored-by: ivy-branch --- ivy/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ivy/__init__.py b/ivy/__init__.py index 5e0cfbfd48cc6..a3ec566d6609e 100644 --- a/ivy/__init__.py +++ b/ivy/__init__.py @@ -7,6 +7,7 @@ import numpy as np import sys import inspect +import importlib import os from collections.abc import Sequence @@ -1540,6 +1541,14 @@ def __setattr__(self, name, value, internal=False): ) self.__dict__[name] = value + def __reduce__(self): + def _get_module_and_replace_name(module_name: str): + module = importlib.import_module(module_name) + module.__class__ = self.__class__ + return module + + return (_get_module_and_replace_name, (self.__name__,)) + if ( "ivy" in sys.modules