docstr: Calculate the average pq for all and every class.
  
  Args:
      isthing (bool|None, optional): calculate average pq for thing class if isthing is True,
          for stuff class if isthing is False and for all if isthing is None. Default: None. Default: None.
      thing_ids (list|None, optional): A list of thing class. It should be provided when isthing is equal to True or False. Default: None.
docstr_tok: ["Calculate","the","average","pq","for","all","and","every","class",".","Args",":","isthing","(","bool|None",",","optional",")",":","calculate","average","pq","for","thing","class","if","isthing","is","True",",","for","stuff","class","if","isthing","is","False","and","for","all","if","isthing","is","None",".","Default",":","None",".","Default",":","None",".","thing_ids","(","list|None",",","optional",")",":","A","list","of","thing","class",".","It","should","be","provided","when","isthing","is","equal","to","True","or","False",".","Default",":","None","."]
code: def pq_average(self, isthing=None, thing_ids=None):
      """
      Calculate the average pq for all and every class.
  
      Args:
          isthing (bool|None, optional): calculate average pq for thing class if isthing is True,
              for stuff class if isthing is False and for all if isthing is None. Default: None. Default: None.
          thing_ids (list|None, optional): A list of thing class. It should be provided when isthing is equal to True or False. Default: None.
      """
      pq, sq, rq, n = 0, 0, 0, 0
      per_class_results = {}
      for label in self.all_ids:
          if isthing is not None:
              if isthing:
                  if label not in thing_ids:
                      continue
              else:
                  if label in thing_ids:
                      continue
          iou = self.pq_per_cat[label].iou
          tp = self.pq_per_cat[label].tp
          fp = self.pq_per_cat[label].fp
          fn = self.pq_per_cat[label].fn
          if tp + fp + fn == 0:
              per_class_results[label] = {
                  "pq": 0.0,
                  "sq": 0.0,
                  "rq": 0.0,
              }
              continue
          n += 1
          pq_class = 100 * iou / (tp + 0.5 * fp + 0.5 * fn)
          sq_class = 100 * iou / tp if tp != 0 else 0
          rq_class = 100 * tp / (tp + 0.5 * fp + 0.5 * fn)
          per_class_results[label] = {
              "pq": pq_class,
              "sq": sq_class,
              "rq": rq_class,
          }
          pq += pq_class
          sq += sq_class
          rq += rq_class
  
      return {
          "pq": pq / n,
          "sq": sq / n,
          "rq": rq / n,
          "n": n,
      }, per_class_results
  
imports: from collections import defaultdict
  import numpy
  from paddlepanseg.cvlibs import build_info_dict
  from paddlepanseg.utils import decode_pan_id
  from .evaluator import Evaluator
label_desc: Use image node_id 4 for calling the PQStat obj's underlying member method code with example usage: obj.pq_average(isthing, thing_ids) and returns: dict,  per_class_results