code: def get_or_create(cls, ex_info, session):
      name = ex_info["name"]
      # Compute a MD5sum of the ex_info to determine its uniqueness
      h = hashlib.md5()
      h.update(json.dumps(ex_info).encode())
      md5 = h.hexdigest()
      instance = (
          session.query(cls).filter_by(name=name, md5sum=md5).first()
      )
      if instance:
          return instance
  
      dependencies = [
          Dependency.get_or_create(d, session)
          for d in ex_info["dependencies"]
      ]
      sources = [
          Source.get_or_create(s, md5sum, session, ex_info["base_dir"])
          for s, md5sum in ex_info["sources"]
      ]
      repositories = set()
      for r in ex_info["repositories"]:
          repository = Repository.get_or_create(
              r["url"], r["commit"], r["dirty"], session
          )
          session.add(repository)
          repositories.add(repository)
      repositories = list(repositories)
  
      return cls(
          name=name,
          dependencies=dependencies,
          sources=sources,
          repositories=repositories,
          md5sum=md5,
          base_dir=ex_info["base_dir"],
      )
  
imports: import hashlib
  import json
  import os
  import sqlalchemy
  from sqlalchemy.ext.declarative import declarative_base
  from sacred.dependencies import get_digest
  from sacred.serializer import restore
label_desc: Use image node_id 1 for calling the Experiment obj's underlying member method code with example usage: obj.get_or_create(cls, ex_info, session) and returns: cls, instance