class_docstr: Test ndarray dunders which delegate to ufuncs, vs ufuncs.
class_docstr_tok: ["Test","ndarray","dunders","which","delegate","to","ufuncs",",","vs","ufuncs","."]
docstr: Test op/iop/rop when the other argument is a scalar of a different dtype.
docstr_tok: ["Test","op\/iop\/rop","when","the","other","argument","is","a","scalar","of","a","different","dtype","."]
code: def test_other_scalar(self, ufunc, op, iop, other_dtype):
      """Test op/iop/rop when the other argument is a scalar of a different dtype."""
      a = np.array([1, 2, 3])
      b = other_dtype(3)
  
      if ufunc in no_complex and issubclass(
          other_dtype, np.complexfloating
      ):
          raise SkipTest(f"{ufunc} does not accept complex.")
  
      # __op__
      result = op(a, b)
      assert_equal(result, ufunc(a, b))
  
      if result.dtype != np.result_type(a, b):
          assert result.dtype == np.result_type(a, b)
  
      # __rop__
      result = op(b, a)
      assert_equal(result, ufunc(b, a))
      if result.dtype != np.result_type(a, b):
          assert result.dtype == np.result_type(a, b)
  
      # __iop__ : casts the result to self.dtype, raises if cannot
      can_cast = np.can_cast(
          np.result_type(a.dtype, other_dtype),
          a.dtype,
          casting="same_kind",
      )
      if can_cast:
          a0 = a.copy()
          result = iop(a, b)
          assert_equal(result, ufunc(a0, b))
          if result.dtype != np.result_type(a, b):
              assert result.dtype == np.result_type(a0, b)
  
      else:
          with assert_raises(
              (TypeError, RuntimeError)
          ):  # XXX np.UFuncTypeError
              iop(a, b)
  
imports: import operator
  from unittest import skipIf, SkipTest
  from pytest import raises
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TEST_WITH_TORCHDYNAMO, TestCase
label_desc: Use image node_id 2 for calling the TestNdarrayDunderVsUfunc obj's underlying member method code with example usage: obj.test_other_scalar(ufunc, op, iop, other_dtype) without return types