code: def _masked_arith_op(x: np.ndarray, y, op):
      """
      If the given arithmetic operation fails, attempt it again on
      only the non-null elements of the input array(s).
  
      Parameters
      ----------
      x : np.ndarray
      y : np.ndarray, Series, Index
      op : binary operator
      """
      # For Series `x` is 1D so ravel() is a no-op; calling it anyway makes
      # the logic valid for both Series and DataFrame ops.
      xrav = x.ravel()
  
      if isinstance(y, np.ndarray):
          dtype = find_common_type([x.dtype, y.dtype])
          result = np.empty(x.size, dtype=dtype)
  
          if len(x) != len(y):
              raise ValueError(x.shape, y.shape)
          ymask = notna(y)
  
          # NB: ravel() is only safe since y is ndarray; for e.g. PeriodIndex
          #  we would get int64 dtype, see GH#19956
          yrav = y.ravel()
          mask = notna(xrav) & ymask.ravel()
  
          # See GH#5284, GH#5035, GH#19448 for historical reference
          if mask.any():
              result[mask] = op(xrav[mask], yrav[mask])
  
      else:
          if not is_scalar(y):
              raise TypeError(
                  f"Cannot broadcast np.ndarray with operand of type { type(y) }"
              )
  
          # mask is only meaningful for x
          result = np.empty(x.size, dtype=x.dtype)
          mask = notna(xrav)
  
          # 1 ** np.nan is 1. So we have to unmask those.
          if op is pow:
              mask = np.where(x == 1, False, mask)
          elif op is roperator.rpow:
              mask = np.where(y == 1, False, mask)
  
          if mask.any():
              result[mask] = op(xrav[mask], y)
  
      np.putmask(result, ~mask, np.nan)
      result = result.reshape(x.shape)  # 2D compat
      return result
  
imports: from __future__ import annotations
  import datetime
  from functools import partial
  import operator
  from typing import TYPE_CHECKING, Any
  import warnings
  import numpy
  from pandas._libs import NaT, Timedelta, Timestamp, lib, ops
  from pandas._libs.tslibs import BaseOffset, get_supported_dtype, is_supported_dtype, is_unitless
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike, find_common_type
  from pandas.core.dtypes.common import ensure_object, is_bool_dtype, is_list_like, is_numeric_v_string_like, is_object_dtype, is_scalar
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries
  from pandas.core.dtypes.missing import isna, notna
  from pandas.core import roperator
  from pandas.core.computation import expressions
  from pandas.core.construction import ensure_wrapped_if_datetimelike
  from pandas.core.ops import missing
  from pandas.core.ops.dispatch import should_extension_dispatch
  from pandas.core.ops.invalid import invalid_comparison
label_desc: Use image node_id 3 for calling a global function with example usage: _masked_arith_op(x, y, op) and returns: result