code: def _calc_norm_ratio(self, model, params, scope, ONE):
      with core.NameScope(scope):
          grad_squared_sums = []
          for i, param in enumerate(params):
              logger.info(param)
              grad = (
                  model.param_to_grad[param]
                  if not isinstance(
                      model.param_to_grad[param],
                      core.GradientSlice,
                  )
                  else model.param_to_grad[param].values
              )
              grad_squared = model.net.Sqr(
                  [grad],
                  "grad_{}_squared".format(i),
              )
              grad_squared_sum = model.net.SumElements(
                  grad_squared,
                  "grad_{}_squared_sum".format(i),
              )
              grad_squared_sums.append(grad_squared_sum)
  
          grad_squared_full_sum = model.net.Sum(
              grad_squared_sums,
              "grad_squared_full_sum",
          )
          global_norm = model.net.Pow(
              grad_squared_full_sum,
              "global_norm",
              exponent=0.5,
          )
          clip_norm = model.param_init_net.ConstantFill(
              [],
              "clip_norm",
              shape=[],
              value=float(self.model_params["max_gradient_norm"]),
          )
          max_norm = model.net.Max(
              [global_norm, clip_norm],
              "max_norm",
          )
          norm_ratio = model.net.Div(
              [clip_norm, max_norm],
              "norm_ratio",
          )
          return norm_ratio
  
imports: import argparse
  import collections
  import logging
  import math
  import numpy
  import random
  import time
  import sys
  import os
  import caffe2.proto.caffe2_pb2
  from caffe2.python import core, workspace, data_parallel_model
  import caffe2.python.models.seq2seq.seq2seq_util
  from caffe2.python.models.seq2seq.seq2seq_model_helper import Seq2SeqModelHelper
label_desc: Use image node_id 6 for calling the Seq2SeqModelCaffe2 obj's underlying member method code with example usage: obj._calc_norm_ratio(model, params, scope, ONE) and returns: norm_ratio