code: def calculate_loss(
      name, np_cached_h, node_label_val, num_classes, args
  ):
      """Calculate loss function."""
      initializer = []
      const_cached_h, init = paddle_helper.constant(
          "const_%s_cached_h" % name, dtype="float32", value=np_cached_h
      )
      initializer.append(init)
  
      node_label, init = paddle_helper.constant(
          "%s_node_label" % (name), dtype="int64", value=node_label_val
      )
      initializer.append(init)
  
      output = fluid.layers.fc(
          const_cached_h,
          size=num_classes,
          bias_attr=args.bias,
          name="fc",
      )
  
      loss, probs = fluid.layers.softmax_with_cross_entropy(
          logits=output, label=node_label, return_softmax=True
      )
      loss = fluid.layers.mean(loss)
  
      acc = None
      if name != "train":
          acc = fluid.layers.accuracy(
              input=probs, label=node_label, k=1
          )
  
      return {
          "loss": loss,
          "acc": acc,
          "probs": probs,
          "initializer": initializer,
      }
  
file_path: PGL/legacy/examples/sgc/sgc.py
imports: import os
  import argparse
  import numpy
  import random
  import time
  import pgl
  from pgl import data_loader
  from pgl.utils.logger import log
  from pgl.utils import paddle_helper
  import paddle.fluid
label_desc: Use image node_id 5 for calling a global function with example usage: calculate_loss(name, np_cached_h, node_label_val, num_classes, args) and returns: dict