code: def _create_magic_methods():
      """
      Set magic methods of cupy.ndarray as methods of fallback.ndarray.
      """
  
      # Decorator for ndarray magic methods
      def make_method(name):
          def method(self, *args, **kwargs):
              CLASS = (
                  cp.ndarray
                  if self._supports_cupy
                  else self._numpy_array.__class__
              )
              _method = getattr(CLASS, name)
              args = (self,) + args
              if self._supports_cupy:
                  return _call_cupy(_method, args, kwargs)
              return _call_numpy(_method, args, kwargs)
  
          method.__doc__ = getattr(np.ndarray, name).__doc__
          return method
  
      for method in (
          # Comparison operators:
          "__eq__",
          "__ne__",
          "__lt__",
          "__gt__",
          "__le__",
          "__ge__",
          # Unary operations:
          "__neg__",
          "__pos__",
          "__abs__",
          "__invert__",
          # Arithmetic:
          "__add__",
          "__sub__",
          "__mul__",
          "__truediv__",
          "__floordiv__",
          "__mod__",
          "__divmod__",
          "__pow__",
          "__lshift__",
          "__rshift__",
          "__and__",
          "__or__",
          "__xor__",
          # Arithmetic, in-place:
          "__iadd__",
          "__isub__",
          "__imul__",
          "__itruediv__",
          "__ifloordiv__",
          "__imod__",
          "__ipow__",
          "__ilshift__",
          "__irshift__",
          "__iand__",
          "__ior__",
          "__ixor__",
          "__matmul__",
          # reflected-methods:
          "__radd__",
          "__rsub__",
          "__rmul__",
          "__rtruediv__",
          "__rfloordiv__",
          "__rmod__",
          "__rdivmod__",
          "__rpow__",
          "__rlshift__",
          "__rrshift__",
          "__rand__",
          "__ror__",
          "__rxor__",
          "__rmatmul__",
          # For standard library functions:
          "__copy__",
          "__deepcopy__",
          "__reduce__",
          # Container customization:
          "__iter__",
          "__len__",
          "__getitem__",
          "__setitem__",
          # Conversion:
          "__bool__",
          "__int__",
          "__float__",
          "__complex__",
          # String representations:
          "__repr__",
          "__str__",
      ):
          setattr(ndarray, method, make_method(method))
  
imports: import types
  import numpy
  import cupy
  from cupyx.fallback_mode import notification
label_desc: Use image node_id 1 for calling a global function with example usage: _create_magic_methods() and returns: method, _call_numpy, _call_cupy