code: def na_logical_op(x: np.ndarray, y, op):
      try:
          # For exposition, write:
          #  yarr = isinstance(y, np.ndarray)
          #  yint = is_integer(y) or (yarr and y.dtype.kind == "i")
          #  ybool = is_bool(y) or (yarr and y.dtype.kind == "b")
          #  xint = x.dtype.kind == "i"
          #  xbool = x.dtype.kind == "b"
          # Then Cases where this goes through without raising include:
          #  (xint or xbool) and (yint or bool)
          result = op(x, y)
      except TypeError:
          if isinstance(y, np.ndarray):
              # bool-bool dtype operations should be OK, should not get here
              assert not (x.dtype.kind == "b" and y.dtype.kind == "b")
              x = ensure_object(x)
              y = ensure_object(y)
              result = libops.vec_binop(x.ravel(), y.ravel(), op)
          else:
              # let null fall thru
              assert lib.is_scalar(y)
              if not isna(y):
                  y = bool(y)
              try:
                  result = libops.scalar_binop(x, y, op)
              except (
                  TypeError,
                  ValueError,
                  AttributeError,
                  OverflowError,
                  NotImplementedError,
              ) as err:
                  typ = type(y).__name__
                  raise TypeError(
                      f"Cannot perform '{op.__name__}' with a dtyped [{x.dtype}] array "
                      f"and scalar of type [{typ}]"
                  ) from err
  
      return result.reshape(x.shape)
  
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 7 for calling a global function with example usage: na_logical_op(x, y, op) and returns: result