code: def maybe_dispatch_ufunc_to_dunder_op(
      ser_or_index: IndexOpsMixin,
      ufunc: Callable,
      method: str,
      *inputs: Any,
      **kwargs: Any,
  ) -> IndexOpsMixin:
      special = {
          "add",
          "sub",
          "mul",
          "pow",
          "mod",
          "floordiv",
          "truediv",
          "divmod",
          "eq",
          "ne",
          "lt",
          "gt",
          "le",
          "ge",
          "remainder",
          "matmul",
      }
      aliases = {
          "absolute": "abs",
          "multiply": "mul",
          "floor_divide": "floordiv",
          "true_divide": "truediv",
          "power": "pow",
          "remainder": "mod",
          "divide": "truediv",
          "equal": "eq",
          "not_equal": "ne",
          "less": "lt",
          "less_equal": "le",
          "greater": "gt",
          "greater_equal": "ge",
      }
  
      # For op(., Array) -> Array.__r{op}__
      flipped = {
          "lt": "__gt__",
          "le": "__ge__",
          "gt": "__lt__",
          "ge": "__le__",
          "eq": "__eq__",
          "ne": "__ne__",
      }
  
      op_name = ufunc.__name__
      op_name = aliases.get(op_name, op_name)
  
      @no_type_check
      def not_implemented(*args, **kwargs):
          return NotImplemented
  
      if (
          method == "__call__"
          and op_name in special
          and kwargs.get("out") is None
      ):
          if isinstance(inputs[0], type(ser_or_index)):
              name = "__{}__".format(op_name)
              return getattr(ser_or_index, name, not_implemented)(
                  inputs[1]
              )
          else:
              name = flipped.get(op_name, "__r{}__".format(op_name))
              return getattr(ser_or_index, name, not_implemented)(
                  inputs[0]
              )
      else:
          return NotImplemented
  
file_path: spark/python/pyspark/pandas/numpy_compat.py
imports: from typing import Any, Callable, no_type_check
  import numpy
  from pyspark.sql import functions
  from pyspark.sql.pandas.functions import pandas_udf
  from pyspark.sql.types import DoubleType, LongType, BooleanType
  from pyspark.pandas.base import IndexOpsMixin
label_desc: Use image node_id 1 for calling a global function with example usage: maybe_dispatch_ufunc_to_dunder_op(ser_or_index, ufunc, method) and returns: NotImplemented, NotImplemented, getattr, getattr