code: def unary_operator(op):
      """
      Factory function for making unary operator methods for Filters.
      """
      valid_ops = {"~"}
      if op not in valid_ops:
          raise ValueError("Invalid unary operator %s." % op)
  
      def unary_operator(self):
          # This can't be hoisted up a scope because the types returned by
          # unary_op_return_type aren't defined when the top-level function is
          # invoked.
          if isinstance(self, NumericalExpression):
              return NumExprFilter.create(
                  "{op}({expr})".format(op=op, expr=self._expr),
                  self.inputs,
              )
          else:
              return NumExprFilter.create(
                  "{op}x_0".format(op=op), (self,)
              )
  
      unary_operator.__doc__ = "Unary Operator: '%s'" % op
      return unary_operator
  
imports: from itertools import chain
  from operator import attrgetter
  from numpy import float64, nan, nanpercentile
  from catalyst.errors import BadPercentileBounds, NonExistentAssetInTimeFrame, UnsupportedDataType
  from catalyst.lib.labelarray import LabelArray
  from catalyst.lib.rank import is_missing
  from catalyst.pipeline.expression import BadBinaryOperator, FILTER_BINOPS, method_name_for_op, NumericalExpression
  from catalyst.pipeline.mixins import AliasedMixin, CustomTermMixin, DownsampledMixin, LatestMixin, PositiveWindowLengthMixin, RestrictedDTypeMixin, SingleInputMixin
  from catalyst.pipeline.term import ComputableTerm, Term
  from catalyst.utils.input_validation import expect_types
  from catalyst.utils.memoize import classlazyval
  from catalyst.utils.numpy_utils import bool_dtype, repeat_first_axis
label_desc: Use image node_id 3 for calling a global function with example usage: unary_operator(op) and returns: unary_operator, NumExprFilter, NumExprFilter