code: def get_credential(
      key: str, validation_func: Callable, generation_func: Callable
  ) -> str:
      """
      This method will try to get a credential and if it isn't supplied or doesn't exist
      it will generate one and save it. If the one supplied doesn't match the one saved
      it will raise an Exception.
      """
      file_credential = get_credentials_file_key(key)
      env_credential = get_env(key)
  
      # supplying a different key means something has gone wrong so raise Exception
      if (
          file_credential != env_credential
          and file_credential is not None
          and env_credential is not None
      ):
          raise Exception(
              f"{key} from ENV must match {key} in {CREDENTIALS_PATH}"
          )
  
      if env_credential is not None and file_credential is None:
          # if there is no key in the credential file but one is passed in ENV then save it
          return save_credential(key, validation_func(env_credential))
      elif file_credential is None and env_credential is None:
          # we can generate one for the user and save it
          return save_credential(
              key, validation_func(generation_func())
          )
      elif file_credential is not None and validation_func(
          file_credential
      ):
          return file_credential
  
      raise Exception("Failed to get or generate Private Key")
  
imports: import argparse
  import json
  import os
  from typing import Callable
  from typing import Dict
  from typing import Optional
  from typing import Union
  import uuid
  from nacl.encoding import HexEncoder
  from nacl.signing import SigningKey
label_desc: Use image node_id 12 for calling a global function with example usage: get_credential(key, validation_func, generation_func) and returns: save_credential, save_credential, file_credential