code: def rs_proto2object(proto: _DynamicStructBuilder) -> Any:
      # relative
      from .deserialize import _deserialize
  
      # clean this mess, Tudor
      module_parts = proto.fullyQualifiedName.split(".")
      klass = module_parts.pop()
      class_type: Type = type(None)
  
      if klass != "NoneType":
          try:
              class_type = index_syft_by_module_name(
                  proto.fullyQualifiedName
              )
          except Exception:  # nosec
              try:
                  class_type = getattr(
                      sys.modules[".".join(module_parts)], klass
                  )
              except Exception:  # nosec
                  if "syft.user" in proto.fullyQualifiedName:
                      # relative
                      from ..node.node import CODE_RELOADER
  
                      for _, load_user_code in CODE_RELOADER.items():
                          load_user_code()
                  try:
                      class_type = getattr(
                          sys.modules[".".join(module_parts)], klass
                      )
                  except Exception:  # nosec
                      pass
  
      if proto.fullyQualifiedName not in TYPE_BANK:
          raise Exception(
              f"{proto.fullyQualifiedName} not in TYPE_BANK"
          )
  
      # TODO: 🐉 sort this out, basically sometimes the syft.user classes are not in the
      # module name space in sub-processes or threads even though they are loaded on start
      # its possible that the uvicorn awsgi server is preloading a bunch of threads
      # however simply getting the class from the TYPE_BANK doesn't always work and
      # causes some errors so it seems like we want to get the local one where possible
      (
          nonrecursive,
          serialize,
          deserialize,
          attribute_list,
          exclude_attrs_list,
          serde_overrides,
          hash_exclude_attrs,
          cls,
          attribute_types,
          version,
      ) = TYPE_BANK[proto.fullyQualifiedName]
  
      if class_type == type(None):
          # yes this looks stupid but it works and the opposite breaks
          class_type = cls
  
      if nonrecursive:
          if deserialize is None:
              raise Exception(
                  f"Cant serialize {type(proto)} nonrecursive without serialize."
              )
  
          return deserialize(combine_bytes(proto.nonrecursiveBlob))
  
      kwargs = {}
  
      for attr_name, attr_bytes_list in zip(
          proto.fieldsName, proto.fieldsData
      ):
          if attr_name != "":
              attr_bytes = combine_bytes(attr_bytes_list)
              attr_value = _deserialize(attr_bytes, from_bytes=True)
              transforms = serde_overrides.get(attr_name, None)
  
              if transforms is not None:
                  attr_value = transforms[1](attr_value)
              kwargs[attr_name] = attr_value
  
      if hasattr(class_type, "serde_constructor"):
          return class_type.serde_constructor(kwargs)
  
      if issubclass(class_type, Enum) and "value" in kwargs:
          obj = class_type.__new__(class_type, kwargs["value"])
      elif issubclass(class_type, BaseModel):
          # if we skip the __new__ flow of BaseModel we get the error
          # AttributeError: object has no attribute '__fields_set__'
  
          if "syft.user" in proto.fullyQualifiedName:
              # weird issues with pydantic and ForwardRef on user classes being inited
              # with custom state args / kwargs
              obj = class_type()
              for attr_name, attr_value in kwargs.items():
                  setattr(obj, attr_name, attr_value)
          else:
              obj = class_type(**kwargs)
  
      else:
          obj = class_type.__new__(class_type)  # type: ignore
          for attr_name, attr_value in kwargs.items():
              setattr(obj, attr_name, attr_value)
  
      return obj
  
imports: from enum import Enum
  from enum import EnumMeta
  import sys
  import types
  from typing import Any
  from typing import Callable
  from typing import List
  from typing import Optional
  from typing import Set
  from typing import Type
  from typing import Union
  from capnp.lib.capnp import _DynamicStructBuilder
  from pydantic import BaseModel
  import syft
  from ..util.util import get_fully_qualified_name
  from ..util.util import index_syft_by_module_name
  from .capnp import get_capnp_schema
label_desc: Use image node_id 8 for calling a global function with example usage: rs_proto2object(proto) and returns: obj, deserialize, class_type