original_docstring: 
          The framework function which use the backend to calculate the value of expectation,
          and be used as the object function in the optimization function of the optimizer
          Args:
              pargs: the value of the parameter alpha and beta in the circuit
              p: the integer used to define the number of layers the current circuit needs to be superimposed
  
          Returns:
              the value of expectation calculated by backends
          
docstring: The framework function which use the backend to calculate the value of expectation,
  and be used as the object function in the optimization function of the optimizer
docstring_tokens: The framework function which use the backend to calculate the value of expectation and be used as the object function in the optimization function of the optimizer
code: def calculate(self, pargs, p=None):
          """
          The framework function which use the backend to calculate the value of expectation,
          and be used as the object function in the optimization function of the optimizer
          Args:
              pargs: the value of the parameter alpha and beta in the circuit
              p: the integer used to define the number of layers the current circuit needs to be superimposed
  
          Returns:
              the value of expectation calculated by backends
          """
          p = self._p if p is None else p
          element_to_graph = self.graph_decomposition(p)
  
          # checking graph type of given problem
          if not isinstance(self._backend, CircuitByTensor):
              for k, v in element_to_graph.items():
                  ncnt, ecnt = len(v.nodes), len(v.edges)
                  try:
                      nreq1 = ncnt * (ncnt - 1) <= 2 * ecnt and ncnt >= 20
                      nreq2 = isinstance(k, int) and v.degree[k] >= 30
                      if nreq1 or nreq2:
                          raise GraphTypeError("The problem is transformed into a dense graph, " \
                             "which is difficult to be solved effectively by Qcover")
                  except GraphTypeError as e:
                      if not self._hard_to_calcute:
                          print(e)
                          self._hard_to_calcute = True
                      # sys.exit()
  
          self._backend._pargs = pargs
          self._backend._element_to_graph = element_to_graph
          return self._backend.expectation_calculation(p)
code_tokens: def calculate ( self , pargs , p = None ) : p = self . _p if p is None else p element_to_graph = self . graph_decomposition ( p ) if not isinstance ( self . _backend , CircuitByTensor ) : for k , v in element_to_graph . items ( ) : ncnt , ecnt = len ( v . nodes ) , len ( v . edges ) try : nreq1 = ncnt * ( ncnt - 1 ) <= 2 * ecnt and ncnt >= 20 nreq2 = isinstance ( k , int ) and v . degree [ k ] >= 30 if nreq1 or nreq2 : raise GraphTypeError ( "The problem is transformed into a dense graph, " "which is difficult to be solved effectively by Qcover" ) except GraphTypeError as e : if not self . _hard_to_calcute : print ( e ) self . _hard_to_calcute = True self . _backend . _pargs = pargs self . _backend . _element_to_graph = element_to_graph return self . _backend . expectation_calculation ( p )
short_docstring: The framework function which use the backend to calculate the value of expectation,
  and be used as the object function in the optimization function of the optimizer
short_docstring_tokens: The framework function which use the backend to calculate the value of expectation and be used as the object function in the optimization function of the optimizer
comment: """
          The framework function which use the backend to calculate the value of expectation,
          and be used as the object function in the optimization function of the optimizer
          Args:
              pargs: the value of the parameter alpha and beta in the circuit
              p: the integer used to define the number of layers the current circuit needs to be superimposed
  
          Returns:
              the value of expectation calculated by backends
          """$SEP$# checking graph type of given problem$SEP$# sys.exit()