code: def testBroadcast(self, dtype, unit):
      # Broadcast pos/len onto input string
      test_string = {
          "BYTE": [
              [b"ten", b"eleven", b"twelve"],
              [b"thirteen", b"fourteen", b"fifteen"],
              [b"sixteen", b"seventeen", b"eighteen"],
              [b"nineteen", b"twenty", b"twentyone"],
          ],
          "UTF8_CHAR": [
              [
                  x.encode("utf-8")
                  for x in [
                      "\U0001d229\U0001d227n",
                      "\xc6\u053c\u025bv\u025bn",
                      "tw\u0c1dlv\u025b",
                  ]
              ],
              [
                  x.encode("utf-8")
                  for x in [
                      "th\xcdrt\xea\xean",
                      "f\U0001f604urt\xea\xean",
                      "f\xcd\ua09ctee\ua0e4",
                  ]
              ],
              [
                  x.encode("utf-8")
                  for x in [
                      "s\xcdxt\xea\xean",
                      "se\U00010299enteen",
                      "ei\U0001e920h\x86een",
                  ]
              ],
              [
                  x.encode("utf-8")
                  for x in ["nineteen", "twenty", "twentyone"]
              ],
          ],
      }[unit]
      position = np.array([1, -4, 3], dtype)
      length = np.array([1, 2, 3], dtype)
      expected_value = {
          "BYTE": [
              [b"e", b"ev", b"lve"],
              [b"h", b"te", b"tee"],
              [b"i", b"te", b"hte"],
              [b"i", b"en", b"nty"],
          ],
          "UTF8_CHAR": [
              [
                  x.encode("utf-8")
                  for x in ["\U0001d227", "\u025bv", "lv\u025b"]
              ],
              [x.encode("utf-8") for x in ["h", "t\xea", "tee"]],
              [x.encode("utf-8") for x in ["\xcd", "te", "h\x86e"]],
              [x.encode("utf-8") for x in ["i", "en", "nty"]],
          ],
      }[unit]
      substr_op = string_ops.substr(
          test_string, position, length, unit=unit
      )
      with self.cached_session():
          substr = self.evaluate(substr_op)
          self.assertAllEqual(substr, expected_value)
  
      # Broadcast input string onto pos/len
      test_string = {
          "BYTE": [b"thirteen", b"fourteen", b"fifteen"],
          "UTF8_CHAR": [
              x.encode("utf-8")
              for x in [
                  "th\xcdrt\xea\xean",
                  "f\U0001f604urt\xea\xean",
                  "f\xcd\ua09ctee\ua0e4",
              ]
          ],
      }[unit]
      position = np.array([[1, -2, 3], [-3, 2, 1], [5, 5, -5]], dtype)
      length = np.array([[3, 2, 1], [1, 2, 3], [2, 2, 2]], dtype)
      expected_value = {
          "BYTE": [
              [b"hir", b"en", b"t"],
              [b"e", b"ur", b"ift"],
              [b"ee", b"ee", b"ft"],
          ],
          "UTF8_CHAR": [
              [x.encode("utf-8") for x in ["h\xcdr", "\xean", "t"]],
              [
                  x.encode("utf-8")
                  for x in ["\xea", "ur", "\xcd\ua09ct"]
              ],
              [
                  x.encode("utf-8")
                  for x in ["\xea\xea", "\xea\xea", "\ua09ct"]
              ],
          ],
      }[unit]
      substr_op = string_ops.substr(
          test_string, position, length, unit=unit
      )
      with self.cached_session():
          substr = self.evaluate(substr_op)
          self.assertAllEqual(substr, expected_value)
  
      # Test 1D broadcast
      test_string = {
          "BYTE": b"thirteen",
          "UTF8_CHAR": "th\xcdrt\xea\xean".encode("utf-8"),
      }[unit]
      position = np.array([1, -4, 7], dtype)
      length = np.array([3, 2, 1], dtype)
      expected_value = {
          "BYTE": [b"hir", b"te", b"n"],
          "UTF8_CHAR": [
              x.encode("utf-8") for x in ["h\xcdr", "t\xea", "n"]
          ],
      }[unit]
      substr_op = string_ops.substr(
          test_string, position, length, unit=unit
      )
      with self.cached_session():
          substr = self.evaluate(substr_op)
          self.assertAllEqual(substr, expected_value)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import string_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 6 for calling the SubstrOpTest obj's underlying member method code with example usage: obj.testBroadcast(dtype, unit) without return types