docstr: This translator performs the basic translation of ONNX nodes into
  Caffe2 operators.  Besides doing a straightforward marshalling from
  one format to another, it also does these extra things:
  
    - Renames operators based on '_renamed_operators'
    - Renames attributes based on '_global_renamed_attrs' and
      '_per_op_renamed_attrs'
  
  If you're writing a custom translator, consider calling this first,
  and then fixing things up further.
docstr_tok: ["This","translator","performs","the","basic","translation","of","ONNX","nodes","into","Caffe2","operators",".","Besides","doing","a","straightforward","marshalling","from","one","format","to","another",",","it","also","does","these","extra","things",":","-","Renames","operators","based","on","'_renamed_operators'","-","Renames","attributes","based","on","'_global_renamed_attrs","'","and","'_per_op_renamed_attrs'","If","you","'re","writing","a","custom","translator",",","consider","calling","this","first",",","and","then","fixing","things","up","further","."]
code: def _common_onnx_node_to_caffe2_op(
      cls, init_model, pred_model, onnx_node, opset_version
  ):
      """
      This translator performs the basic translation of ONNX nodes into
      Caffe2 operators.  Besides doing a straightforward marshalling from
      one format to another, it also does these extra things:
  
        - Renames operators based on '_renamed_operators'
        - Renames attributes based on '_global_renamed_attrs' and
          '_per_op_renamed_attrs'
  
      If you're writing a custom translator, consider calling this first,
      and then fixing things up further.
      """
      c2_op = caffe2_pb2.OperatorDef()
  
      c2_op.input.extend(onnx_node.inputs)
      c2_op.output.extend(onnx_node.outputs)
      c2_op.name = onnx_node.name
  
      onnx_op_type = onnx_node.op_type
      broken_version = cls._broken_operators.get(
          onnx_op_type, float("Inf")
      )
      if broken_version <= opset_version:
          raise ValueError(
              "Don't know how to translate op {} in ONNX operator set v{} (I only support prior to v{})".format(
                  onnx_op_type, opset_version, broken_version
              )
          )
      c2_op.type = cls._renamed_operators.get(
          onnx_op_type, onnx_op_type
      )
      if not core.IsOperator(c2_op.type):
          raise ValueError(
              "Don't know how to translate op {}".format(onnx_op_type)
          )
  
      def kmap(k):
          if (
              onnx_op_type in cls._per_op_renamed_attrs
              and k in cls._per_op_renamed_attrs[onnx_op_type]
          ):
              return cls._per_op_renamed_attrs[onnx_op_type][k]
          if k in cls._global_renamed_attrs:
              return cls._global_renamed_attrs[k]
          return k
  
      c2_op.arg.extend(onnx_node.attrs.caffe2(kmap=kmap))
  
      if opset_version < 7:
          # onnx opset 7 and newest caffe2 have adopted full onnx broadcast semantics
          # so we don't need this hack anymore
          if c2_op.type in cls._broadcast_operators:
              already_broadcast = False
              for arg in c2_op.arg:
                  if arg.name == "broadcast":
                      already_broadcast = True
              if not already_broadcast:
                  c2_op.arg.extend(
                      [caffe2.python.utils.MakeArgument("broadcast", 1)]
                  )
  
      return c2_op
  
imports: import collections
  import sys
  import zipfile
  import itertools
  import onnx.backend
  from caffe2.python import core, workspace, rnn_cell, gru_cell
  from caffe2.python.model_helper import ModelHelper
  from caffe2.proto import caffe2_pb2
  import caffe2.python.utils
  import numpy
  import onnx
  from onnx import TensorProto
  import onnx.numpy_helper
  import onnx.defs
  import onnx.shape_inference
  import onnx.utils
  from onnx.backend.base import Backend, Device, DeviceType, namedtupledict
  from caffe2.python.onnx.workspace import Workspace
  from caffe2.python.onnx.backend_rep import Caffe2Rep
  import caffe2.python._import_c_extension
  import warnings
label_desc: Use image node_id 20 for calling the Caffe2Backend obj's underlying member method code with example usage: obj._common_onnx_node_to_caffe2_op(cls, init_model, pred_model, onnx_node, opset_version) and returns: c2_op, k, cls, cls