class_docstr: The dual task loss implement of GSCNN
  
  Args:
      ignore_index (int64): Specifies a target value that is ignored
          and does not contribute to the input gradient. Default ``255``.
      tau (float): the tau of gumbel softmax sample.
class_docstr_tok: ["The","dual","task","loss","implement","of","GSCNN","Args",":","ignore_index","(","int64",")",":","Specifies","a","target","value","that","is","ignored","and","does","not","contribute","to","the","input","gradient",".","Default","``","255","``",".","tau","(","float",")",":","the","tau","of","gumbel","softmax","sample","."]
code: def compute_grad_mag(self, x):
      eps = 1e-6
      n, c, h, w = x.shape
      if h <= 1 or w <= 1:
          raise ValueError(
              "The width and height of tensor to compute grad must be greater than 1, but the shape is {}.".format(
                  x.shape
              )
          )
  
      x = self.conv_tri(x, r=4)
      kernel = [[-1, 0, 1]]
      kernel = paddle.to_tensor(kernel).astype("float32")
      kernel = 0.5 * kernel
  
      kernel_x = paddle.concat([kernel.unsqueeze((0, 1))] * c, axis=0)
      grad_x = F.conv2d(x, kernel_x, padding="same", groups=c)
      kernel_y = paddle.concat(
          [kernel.t().unsqueeze((0, 1))] * c, axis=0
      )
      grad_y = F.conv2d(x, kernel_y, padding="same", groups=c)
      mag = paddle.sqrt(grad_x * grad_x + grad_y * grad_y + eps)
  
      return mag / mag.max()
  
file_path: PaddleSeg/paddleseg/models/losses/gscnn_dual_task_loss.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager
label_desc: Use image node_id 3 for calling the DualTaskLoss obj's underlying member method code with example usage: obj.compute_grad_mag(x) and returns: unknown