code: def test_cast(self):
      X = np.random.randn(1, 2, 3).astype(np.float32)
  
      for to_type in [
          "INT8",
          caffe2_pb2.TensorProto.INT8,
          "DOUBLE",
          caffe2_pb2.TensorProto.DOUBLE,
      ]:
          predict_net = caffe2_pb2.NetDef()
          predict_net.name = "test-cast-net"
          predict_net.external_input[:] = ["X"]
          predict_net.external_output[:] = ["Y"]
          predict_net.op.extend(
              [
                  core.CreateOperator(
                      "Cast",
                      inputs=["X"],
                      outputs=["Y"],
                      to=to_type,
                  ),
              ]
          )
          ws, c2_outputs = c2_native_run_net(
              init_net=None, predict_net=predict_net, inputs=[X]
          )
  
          onnx_model = c2_onnx.caffe2_net_to_onnx_model(
              predict_net=predict_net,
              value_info={
                  "X": (
                      onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[X.dtype],
                      X.shape,
                  )
              },
          )
          onnx_outputs = c2.run_model(onnx_model, inputs=[X])
          self.assertSameOutputs(c2_outputs, onnx_outputs)
  
imports: import os
  import unittest
  from caffe2.python import core
  from caffe2.proto import caffe2_pb2
  import onnx
  from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
  from caffe2.python.onnx.helper import c2_native_run_net, c2_native_run_op
  from onnx import mapping
  import caffe2.python.onnx.frontend
  import caffe2.python.onnx.backend
  import numpy
  from caffe2.python.models.download import ModelDownloader
  from caffe2.python.onnx.tests.test_utils import TestCase
  import caffe2.python._import_c_extension
label_desc: Use image node_id 18 for calling the TestCaffe2Basic obj's underlying member method code with example usage: obj.test_cast() without return types