code: def _reduce_with_dtype(onnx_op, name):
      symbolic = _reduce_op_symbolic(onnx_op)
  
      @opset9.overload_by_arg_count
      @_beartype.beartype
      def reduce(g, *args, **kwargs):
          @symbolic_helper.parse_args("v", "none")
          @_beartype.beartype
          def reduce_nodim(g, self, dtype):
              dtype_onnx = None
              if dtype.node().kind() == "onnx::Constant":
                  dtype = symbolic_helper._get_const(
                      dtype, "i", "dtype"
                  )
                  dtype_onnx = _type_utils.JitScalarType(
                      dtype
                  ).onnx_type()
                  self = g.op("Cast", self, to_i=dtype_onnx)
              elif dtype.node().kind() != "prim::Constant":
                  return symbolic_helper._unimplemented(
                      name, "dtype", dtype
                  )
              result = symbolic(g, self)
              if dtype_onnx is not None:
                  result_dtype_onnx = (
                      _type_utils.JitScalarType.from_value(
                          result
                      ).onnx_type()
                  )
                  if result_dtype_onnx != dtype_onnx:
                      result = g.op("Cast", result, to_i=dtype_onnx)
              return result
  
          @symbolic_helper.parse_args("v", "v", "i", "none")
          @_beartype.beartype
          def reduce_dim(g, self, dim, keepdim, dtype):
              dtype_onnx = None
              if dtype.node().kind() == "onnx::Constant":
                  dtype = symbolic_helper._get_const(
                      dtype, "i", "dtype"
                  )
                  dtype_onnx = _type_utils.JitScalarType(
                      dtype
                  ).onnx_type()
                  self = g.op("Cast", self, to_i=dtype_onnx)
              elif dtype.node().kind() != "prim::Constant":
                  return symbolic_helper._unimplemented(
                      name, "dtype", dtype
                  )
              result = symbolic(g, self, dim, keepdim)
              if dtype_onnx is not None:
                  result_dtype_onnx = (
                      _type_utils.JitScalarType.from_value(
                          result
                      ).onnx_type()
                  )
                  if result_dtype_onnx != dtype_onnx:
                      result = g.op("Cast", result, to_i=dtype_onnx)
              return result
  
          return reduce_nodim, reduce_dim
  
      return reduce
  
imports: import functools
  import torch
  import torch._C._onnx
  from torch.onnx import _constants, _type_utils, errors, symbolic_helper, symbolic_opset11, symbolic_opset9, utils
  from torch.onnx._internal import _beartype, jit_utils, registration
label_desc: Use image node_id 16 for calling a global function with example usage: _reduce_with_dtype(onnx_op, name) and returns: reduce, reduce_nodim,  reduce_dim, result, result, symbolic_helper, symbolic_helper