docs: def insert_graph(self, graph: BELGraph, store_parts: bool = True, use_tqdm: bool = False) -> Network:
          """Insert a graph in the database and returns the corresponding Network model.
  
          :raises: pybel.resources.exc.ResourceError
          """
          if not graph.name:
              raise ValueError('Can not upload a graph without a name')
  
          if not graph.version:
              raise ValueError('Can not upload a graph without a version')
  
          log.debug('inserting %s v%s', graph.name, graph.version)
  
          t = time.time()
  
          self.ensure_default_namespace()
  
          namespace_urls = graph.namespace_url.values()
          if use_tqdm:
              namespace_urls = tqdm(namespace_urls, desc='namespaces')
  
          for namespace_url in namespace_urls:
              if namespace_url not in graph.uncached_namespaces:
                  self.get_or_create_namespace(namespace_url)
  
          for keyword, pattern in graph.namespace_pattern.items():
              self.ensure_regex_namespace(keyword, pattern)
  
          annotation_urls = graph.annotation_url.values()
          if use_tqdm:
              annotation_urls = tqdm(annotation_urls, desc='annotations')
  
          for annotation_url in annotation_urls:
              self.get_or_create_annotation(annotation_url)
  
          network = Network(**{
              key: value
              for key, value in graph.document.items()
              if key in METADATA_INSERT_KEYS
          })
  
          network.store_bel(graph)
  
          if store_parts:
              network.nodes, network.edges = self._store_graph_parts(graph, use_tqdm=use_tqdm)
  
          self.session.add(network)
          self.session.commit()
  
          log.info('inserted %s v%s in %.2f seconds', graph.name, graph.version, time.time() - t)
  
          return network