docstr: Given an Onnx TensorProto, translate it into a Caffe2 operator
  which produces the given tensor filling op.
docstr_tok: ["Given","an","Onnx","TensorProto",",","translate","it","into","a","Caffe2","operator","which","produces","the","given","tensor","filling","op","."]
code: def _create_tensor_filling_op(cls, onnx_tensor, name=None):
      """
      Given an Onnx TensorProto, translate it into a Caffe2 operator
      which produces the given tensor filling op.
      """
      assert name or onnx_tensor.name
      name = name or onnx_tensor.name
  
      c2_op = caffe2_pb2.OperatorDef()
  
      c2_values = c2_op.arg.add()
      c2_values.name = "values"
  
      def tensor2list(onnx_tensor):
          # Use the onnx.numpy_helper because the data may be raw
          return (
              onnx.numpy_helper.to_array(onnx_tensor).flatten().tolist()
          )
  
      if onnx_tensor.data_type in [TensorProto.FLOAT]:
          c2_op.type = "GivenTensorFill"
          c2_values.floats.extend(tensor2list(onnx_tensor))
      elif onnx_tensor.data_type in [TensorProto.DOUBLE]:
          c2_op.type = "GivenTensorDoubleFill"
          c2_values.floats.extend(tensor2list(onnx_tensor))
      elif onnx_tensor.data_type in [
          TensorProto.INT64,
          TensorProto.UINT32,
      ]:
          c2_op.type = "GivenTensorInt64Fill"
          c2_values.ints.extend(tensor2list(onnx_tensor))
      elif onnx_tensor.data_type in [
          TensorProto.UINT8,
          TensorProto.INT8,
          TensorProto.UINT16,
          TensorProto.INT16,
          TensorProto.INT32,
      ]:
          c2_op.type = "GivenTensorIntFill"
          c2_values.ints.extend(tensor2list(onnx_tensor))
      elif onnx_tensor.data_type == TensorProto.BOOL:
          c2_op.type = "GivenTensorBoolFill"
          c2_values.ints.extend(tensor2list(onnx_tensor))
      elif onnx_tensor.data_type == TensorProto.STRING:
          c2_op.type = "GivenTensorStringFill"
          c2_values.strings.extend(onnx_tensor.string_data)
      else:
          raise RuntimeError(
              "unrecognized tensor type {}".format(
                  onnx_tensor.data_type
              )
          )
  
      c2_shape = c2_op.arg.add()
      c2_shape.name = "shape"
      c2_shape.ints.extend(onnx_tensor.dims)
  
      c2_op.output.append(name)
  
      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 3 for calling the Caffe2Backend obj's underlying member method code with example usage: obj._create_tensor_filling_op(cls, onnx_tensor, name) and returns: c2_op, onnx