docstr: Build graph topology for each item in the dataset. The generated graph is bound to
  the `graph` attribute of the DataItem.
docstr_tok: ["Build","graph","topology","for","each","item","in","the","dataset",".","The","generated","graph","is","bound","to","the","`","graph","`","attribute","of","the","DataItem","."]
code: def _build_topology_process(
      self,
      data_items,
      topology_builder,
      static_or_dynamic,
      graph_name,
      dynamic_init_topology_builder,
      merge_strategy,
      edge_strategy,
      dynamic_init_topology_aux_args,
      lower_case,
      tokenizer,
      port,
      timeout,
  ):
      """
      Build graph topology for each item in the dataset. The generated graph is bound to
      the `graph` attribute of the DataItem.
      """
  
      print("using conll dataset!")
      if self.static_or_dynamic not in ["static", "dynamic"]:
          raise ValueError(
              "Argument: ``static_or_dynamic`` must be ``static`` or ``dynamic``"
          )
  
      if self.static_or_dynamic == "static":
          if (
              self.topology_builder
              == DependencyBasedGraphConstruction_without_tokenizer
          ):
              print("Connecting to stanfordcorenlp server...")
              processor = stanfordcorenlp.StanfordCoreNLP(
                  "http://localhost", port=9000, timeout=1000
              )
              processor_args = {
                  "annotators": "ssplit,tokenize,depparse",
                  "tokenize.options": "splitHyphenated=false,normalizeParentheses=false,\
                          normalizeOtherBrackets=false",
                  "tokenize.whitespace": False,
                  "ssplit.isOneSentence": False,
                  "outputFormat": "json",
              }
              for item in data_items:
                  graph = self.topology_builder.static_topology(
                      raw_text_data=item.input_text,
                      auxiliary_args=self.depedency_topology_aux_args,
                  )
                  item.graph = graph
  
          elif self.topology_builder == LineBasedGraphConstruction:
              processor = None
              processor_args = {
                  "annotators": "ssplit,tokenize,depparse",
                  "tokenize.options": "splitHyphenated=false,normalizeParentheses=false,\
                          normalizeOtherBrackets=false",
                  "tokenize.whitespace": False,
                  "ssplit.isOneSentence": False,
                  "outputFormat": "json",
              }
              for item in data_items:
                  graph = self.topology_builder.static_topology(
                      raw_text_data=item.input_text,
                      merge_strategy=self.merge_strategy,
                      edge_strategy=self.edge_strategy,
                      nlp_processor=None,
                      processor_args=None,
                  )
                  item.graph = graph
  
          else:
              raise NotImplementedError(
                  "unknown static graph type: {}".format(
                      self.graph_name
                  )
              )
  
          print("CoreNLP server is connected!")
  
      elif self.static_or_dynamic == "dynamic":
          if self.graph_name == "node_emb":
              for item in data_items:
                  graph = self.topology_builder.init_topology(
                      item.input_text,
                      lower_case=self.lower_case,
                      tokenizer=self.tokenizer,
                  )
  
                  item.graph = graph
  
          elif self.graph_name == "node_emb_refined":
              if (
                  self.dynamic_init_topology_builder
                  == DependencyBasedGraphConstruction_without_tokenizer
              ):
                  print("Connecting to stanfordcorenlp server...")
                  processor = stanfordcorenlp.StanfordCoreNLP(
                      "http://localhost", port=9000, timeout=1000
                  )
                  print("CoreNLP server connected.")
                  processor_args = {
                      "annotators": "ssplit,tokenize,depparse",
                      "tokenize.options": "splitHyphenated=false,normalizeParentheses=false,\
                              normalizeOtherBrackets=false",
                      "tokenize.whitespace": False,
                      "ssplit.isOneSentence": False,
                      "outputFormat": "json",
                  }
              else:
                  processor = None
                  processor_args = None
  
              self.dynamic_init_topology_aux_args = {
                  "lower_case": self.lower_case,
                  "tokenizer": self.tokenizer,
                  "merge_strategy": self.merge_strategy,
                  "edge_strategy": self.edge_strategy,
                  "verbose": False,
                  "nlp_processor": processor,
                  "processor_args": processor_args,
              }
  
              for item in data_items:
                  graph = self.topology_builder.init_topology(
                      item.input_text,
                      dynamic_init_topology_builder=self.dynamic_init_topology_builder,
                      dynamic_init_topology_aux_args=self.dynamic_init_topology_aux_args,
                  )
  
                  item.graph = graph
          else:
              raise RuntimeError(
                  "Unknown graph_name: {}".format(
                      self.dynamic_graph_name
                  )
              )
  
      else:
          raise NotImplementedError(
              "Currently only static and dynamic are supported!"
          )
      return data_items
  
imports: from copy import deepcopy
  import stanfordcorenlp
  import torch
  from graph4nlp.pytorch.data.data import GraphData
  from graph4nlp.pytorch.data.dataset import SequenceLabelingDataset
  from dependency_graph_construction_without_tokenize import DependencyBasedGraphConstruction_without_tokenizer
  from line_graph_construction import LineBasedGraphConstruction
label_desc: Use image node_id 4 for calling the ConllDataset_inference obj's underlying member method code with example usage: obj._build_topology_process(data_items, topology_builder, static_or_dynamic, graph_name, dynamic_init_topology_builder, merge_strategy, edge_strategy, dynamic_init_topology_aux_args, lower_case, tokenizer, port, timeout) and returns: data_items