code: def submit_version(
      self,
      context: AuthedServiceContext,
      code: Union[SubmitUserCode, UserCode],
      comment: Optional[str] = None,
  ) -> Union[SyftSuccess, SyftError]:
      user_code_service = context.node.get_service("usercodeservice")
  
      final_result = None
      if isinstance(code, SubmitUserCode):
          result = user_code_service._submit(context=context, code=code)
          if result.is_err():
              return SyftError(message=str(result.err()))
          code: UserCode = result.ok()
  
      elif isinstance(code, UserCode):
          result = user_code_service.get_by_uid(
              context=context, uid=code.id
          )
          if isinstance(result, SyftError):
              return result
          code: UserCode = result
  
      result = self.stash.get_by_service_func_name_and_verify_key(
          credentials=context.credentials,
          service_func_name=code.service_func_name,
          user_verify_key=context.credentials,
      )
  
      if result.is_err():
          return SyftError(message=result.err())
  
      code_history: CodeHistory = result.ok()
  
      if code_history is None:
          code_history = CodeHistory(
              id=UID(),
              node_uid=context.node.id,
              user_verify_key=context.credentials,
              service_func_name=code.service_func_name,
          )
          result = self.stash.set(
              credentials=context.credentials, obj=code_history
          )
          if result.is_err():
              return SyftError(message=result.err())
  
      code_history.add_code(code=code, comment=comment)
      result = self.stash.update(
          credentials=context.credentials, obj=code_history
      )
      if result.is_err():
          return SyftError(message=result.err())
  
      if final_result is None:
          return SyftSuccess(message="Code version submit success")
      else:
          return final_result
  
imports: from typing import List
  from typing import Optional
  from typing import Union
  from ...serde.serializable import serializable
  from ...store.document_store import DocumentStore
  from ...types.uid import UID
  from ...util.telemetry import instrument
  from ..code.user_code import SubmitUserCode
  from ..code.user_code import UserCode
  from ..context import AuthedServiceContext
  from ..response import SyftError
  from ..response import SyftSuccess
  from ..service import AbstractService
  from ..service import service_method
  from ..user.user_roles import DATA_OWNER_ROLE_LEVEL
  from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL
  from .code_history import CodeHistoriesDict
  from .code_history import CodeHistory
  from .code_history import CodeHistoryView
  from .code_history import UsersCodeHistoriesDict
  from .code_history_stash import CodeHistoryStash
label_desc: Use image node_id 2 for calling the CodeHistoryService obj's underlying member method code with example usage: obj.submit_version(context, code, comment) and returns: SyftError, SyftError, SyftSuccess, final_result, SyftError, SyftError, result