code: def _AddGradientOperators(devices, model, losses_by_gpu):
      def create_grad(lossp):
          return model.ConstantFill(
              lossp, str(lossp) + "_grad", value=1.0
          )
  
      loss_grad = {}
      # Explicitly need to create gradients on each GPU
      for gpu_id in devices:
          device = core.DeviceOption(model._device_type, gpu_id)
          with core.DeviceScope(device):
              for l in losses_by_gpu[gpu_id]:
                  lg = create_grad(l)
                  loss_grad[str(l)] = str(lg)
  
      model.AddGradientOperators(loss_grad)
  
imports: from collections import OrderedDict
  import logging
  import copy
  from multiprocessing import cpu_count
  from caffe2.python import model_helper, dyndep, scope, workspace, core, memonger, utils
  from caffe2.proto import caffe2_pb2
  import numpy
  import warnings
label_desc: Use image node_id 17 for calling a global function with example usage: _AddGradientOperators(devices, model, losses_by_gpu) and returns: model