code: def _ragged_substr(text_input, begin, end):
      text_input_flat = None
      if ragged_tensor.is_ragged(text_input):
          text_input_flat = text_input.flat_values
      else:
          text_input_flat = text_input
  
      def _ragged_tile(x):
          input_text, indices = x
          multiple = math_ops.reduce_sum(indices.row_lengths())
          return array_ops.tile([input_text], [multiple])
  
      broadcasted_text = ragged_map_ops.map_fn(
          _ragged_tile,
          (text_input_flat, begin),
          dtype=ragged_tensor.RaggedTensorType(
              dtype=dtypes.string, ragged_rank=1
          ),
          infer_shape=False,
      )
      size = math_ops.sub(
          array_ops.squeeze(end.flat_values),
          array_ops.squeeze(begin.flat_values),
      )
      new_tokens = string_ops.substr_v2(
          broadcasted_text, array_ops.squeeze(begin.flat_values), size
      )
      return begin.with_flat_values(new_tokens.flat_values)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import lookup_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import string_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_map_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import test
  from tensorflow_text.python.ops import bert_tokenizer
label_desc: Use image node_id 2 for calling a global function with example usage: _ragged_substr(text_input, begin, end) and returns: begin, array_ops