code: def test_net_gradient_checker(self):
      model = model_helper.ModelHelper(name="test")
      const = model.net.AddExternalInputs("const1", "const2")
      fc = brew.fc(
          model, dim_in=3, dim_out=4, blob_in="X", blob_out="Y", axis=0
      )
      dist = [model.net.SquaredL2Distance([fc, c]) for c in const]
      losses = [
          model.net.AveragedLoss(d) for d in dist
      ]  # using two losses here
  
      workspace.RunNetOnce(model.param_init_net)
      NetGradientChecker.Check(
          model.net,
          outputs_with_grad=losses,
          input_values={
              "X": np.array([1, 2, 3], dtype="float32"),
              const[0]: np.array([1, 1, 1, 1], dtype="float32"),
              const[1]: np.array([2, 2, 2, 2], dtype="float32"),
          },
          input_to_check="X",
      )
  
imports: import numpy
  from caffe2.python import brew, core, device_checker, gradient_checker, model_helper, test_util, workspace
  from caffe2.python.gradient_checker import NetGradientChecker
  from caffe2.python.net_builder import ops, NetBuilder
  from caffe2.proto import caffe2_pb2
  import unittest
  from typing import Optional
label_desc: Use image node_id 1 for calling the TestNetGradientChecker obj's underlying member method code with example usage: obj.test_net_gradient_checker() without return types