code: def testReplaceErrors(self, encoding):
      test_value = np.array(
          [ord("H"), ord("e"), 0x7FFFFFFF, -1, ord("o")], np.int32
      )
      expected_value = "He\U0000fffd\U0000fffdo".encode(encoding)
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding, "replace"
      )
      self.assertAllEqual(unicode_encode_op, expected_value)
  
      # Test custom replacement character
      test_value = np.array(
          [ord("H"), ord("e"), 0x7FFFFFFF, -1, ord("o")], np.int32
      )
      expected_value = "Heooo".encode(encoding)
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding, "replace", ord("o")
      )
      self.assertAllEqual(unicode_encode_op, expected_value)
  
      # Verify "replace" is default
      test_value = np.array(
          [ord("H"), ord("e"), 0x7FFFFFFF, -1, ord("o")], np.int32
      )
      expected_value = "He\U0000fffd\U0000fffdo".encode(encoding)
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding
      )
      self.assertAllEqual(unicode_encode_op, expected_value)
  
      # Verify non-default replacement with an unpaired surrogate.
      test_value = np.array([0xD801], np.int32)
      expected_value = "A".encode(encoding)
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding, "replace", 0x41
      )
      self.assertAllEqual(unicode_encode_op, expected_value)
  
      # Test with a noncharacter code point.
      test_value = np.array([0x1FFFF], np.int32)
      expected_value = "A".encode(encoding)
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding, "replace", 0x41
      )
      self.assertAllEqual(unicode_encode_op, expected_value)
  
      # Replacement_char must be within range
      test_value = np.array(
          [ord("H"), ord("e"), 0x7FFFFFFF, -1, ord("o")], np.int32
      )
      unicode_encode_op = ragged_string_ops.unicode_encode(
          test_value, encoding, "replace", 0x110000
      )
      with self.assertRaises(errors.InvalidArgumentError):
          self.evaluate(unicode_encode_op)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_string_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.ops.ragged import ragged_tensor_value
  from tensorflow.python.platform import test
label_desc: Use image node_id 6 for calling the UnicodeEncodeOpTest obj's underlying member method code with example usage: obj.testReplaceErrors(encoding) without return types