code: def make_arithmetic_op(op):
      """
      Make closures that implement arithmetic operations. See
      register_arithmetic_op for details.
      """
  
      def masked_scalar_op_impl(context, builder, sig, args):
          """
          Implement `MaskedType` <op> `MaskedType`
          """
          # MaskedType(...), MaskedType(...)
          masked_type_1, masked_type_2 = sig.args
          # MaskedType(...)
          masked_return_type = sig.return_type
  
          # Let there be two actual LLVM structs backing the two inputs
          # https://mapping-high-level-constructs-to-llvm-ir.readthedocs.io/en/latest/basic-constructs/structures.html
          m1 = cgutils.create_struct_proxy(masked_type_1)(
              context, builder, value=args[0]
          )
          m2 = cgutils.create_struct_proxy(masked_type_2)(
              context, builder, value=args[1]
          )
  
          # we will return an output struct
          result = cgutils.create_struct_proxy(masked_return_type)(
              context, builder
          )
          # compute output validity
          valid = builder.and_(m1.valid, m2.valid)
          result.valid = valid
          with builder.if_then(valid):
              # Let numba handle generating the extra IR needed to perform
              # operations on mixed types, by compiling the final core op between
              # the two primitive values as a separate function and calling it
              result.value = context.compile_internal(
                  builder,
                  lambda x, y: op(x, y),
                  nb_signature(
                      masked_return_type.value_type,
                      masked_type_1.value_type,
                      masked_type_2.value_type,
                  ),
                  (m1.value, m2.value),
              )
          return result._getvalue()
  
      return masked_scalar_op_impl
  
imports: import operator
  from llvmlite import ir
  from numba.core import cgutils
  from numba.core.typing import signature
  from numba.cuda.cudaimpl import lower, registry
  from numba.extending import lower_builtin, types
  from cudf.core.udf import api
  from cudf.core.udf._ops import arith_ops, bitwise_ops, comparison_ops, unary_ops
  from cudf.core.udf.masked_typing import MaskedType, NAType, _supported_masked_types
label_desc: Use image node_id 2 for calling a global function with example usage: make_arithmetic_op(op) and returns: masked_scalar_op_impl, result