class_docstr: Splits a string tensor into bytes.
class_docstr_tok: ["Splits","a","string","tensor","into","bytes","."]
docstr: Splits a string tensor into bytes.
  
  The strings are split bytes. Thus, some unicode characters may be split
  into multiple bytes.
  
  Example:
  
  >>> splitter = ByteSplitter()
  >>> bytes, starts, ends = splitter.split_with_offsets("hello")
  >>> print(bytes.numpy(), starts.numpy(), ends.numpy())
  [104 101 108 108 111] [0 1 2 3 4] [1 2 3 4 5]
  
  Args:
    input: A `RaggedTensor` or `Tensor` of strings with any shape.
  
  Returns:
    A `RaggedTensor` of bytes. The returned shape is the shape of the
    input tensor with an added ragged dimension for the bytes that make up
    each string.
  
  Returns:
    A tuple `(bytes, offsets)` where:
  
      * `bytes`: A `RaggedTensor` of bytes.
      * `start_offsets`: A `RaggedTensor` of the bytes' starting byte offset.
      * `end_offsets`: A `RaggedTensor` of the bytes' ending byte offset.
docstr_tok: ["Splits","a","string","tensor","into","bytes",".","The","strings","are","split","bytes",".","Thus",",","some","unicode","characters","may","be","split","into","multiple","bytes",".","Example",":",">",">",">","splitter","=","ByteSplitter","(",")",">",">",">","bytes",",","starts",",","ends","=","splitter.split_with_offsets","(","``","hello","''",")",">",">",">","print","(","bytes.numpy","(",")",",","starts.numpy","(",")",",","ends.numpy","(",")",")","[","104","101","108","108","111","]","[","0","1","2","3","4","]","[","1","2","3","4","5","]","Args",":","input",":","A","`","RaggedTensor","`","or","`","Tensor","`","of","strings","with","any","shape",".","Returns",":","A","`","RaggedTensor","`","of","bytes",".","The","returned","shape","is","the","shape","of","the","input","tensor","with","an","added","ragged","dimension","for","the","bytes","that","make","up","each","string",".","Returns",":","A","tuple","`","(","bytes",",","offsets",")","`","where",":","*","`","bytes","`",":","A","`","RaggedTensor","`","of","bytes",".","*","`","start_offsets","`",":","A","`","RaggedTensor","`","of","the","bytes","'","starting","byte","offset",".","*","`","end_offsets","`",":","A","`","RaggedTensor","`","of","the","bytes","'","ending","byte","offset","."]
code: def split_with_offsets(
      self, input
  ):  # pylint: disable=redefined-builtin
      """Splits a string tensor into bytes.
  
      The strings are split bytes. Thus, some unicode characters may be split
      into multiple bytes.
  
      Example:
  
      >>> splitter = ByteSplitter()
      >>> bytes, starts, ends = splitter.split_with_offsets("hello")
      >>> print(bytes.numpy(), starts.numpy(), ends.numpy())
      [104 101 108 108 111] [0 1 2 3 4] [1 2 3 4 5]
  
      Args:
        input: A `RaggedTensor` or `Tensor` of strings with any shape.
  
      Returns:
        A `RaggedTensor` of bytes. The returned shape is the shape of the
        input tensor with an added ragged dimension for the bytes that make up
        each string.
  
      Returns:
        A tuple `(bytes, offsets)` where:
  
          * `bytes`: A `RaggedTensor` of bytes.
          * `start_offsets`: A `RaggedTensor` of the bytes' starting byte offset.
          * `end_offsets`: A `RaggedTensor` of the bytes' ending byte offset.
      """
      name = None
      with ops.name_scope(name, "ByteSplitter", [input]):
          input_tensor = (
              ragged_tensor.convert_to_tensor_or_ragged_tensor(input)
          )
          if input_tensor.shape.ndims is None:
              raise ValueError(
                  "Rank of input_tensor must be statically known."
              )
          if ragged_tensor.is_ragged(input_tensor):
              if input_tensor.flat_values.shape.ndims > 1:
                  # If the flat_values of our ragged tensor is multi-dimensional, we can
                  # process it separately and our output will have the same nested
                  # splits as our input.
                  (
                      bytez,
                      start_offsets,
                      end_offsets,
                  ) = self.split_with_offsets(input_tensor.flat_values)
                  return (
                      input_tensor.with_flat_values(bytez),
                      input_tensor.with_flat_values(start_offsets),
                      input_tensor.with_flat_values(end_offsets),
                  )
              else:
                  # Recursively process the values of the ragged tensor.
                  (
                      bytez,
                      start_offsets,
                      end_offsets,
                  ) = self.split_with_offsets(input_tensor.values)
                  return (
                      input_tensor.with_values(bytez),
                      input_tensor.with_values(start_offsets),
                      input_tensor.with_values(end_offsets),
                  )
          else:
              if input_tensor.shape.ndims > 1:
                  # Convert the input tensor to ragged and process it.
                  return self.split_with_offsets(
                      ragged_conversion_ops.from_tensor(input_tensor)
                  )
              elif input_tensor.shape.ndims == 0:
                  (
                      bytez,
                      start_offsets,
                      end_offsets,
                  ) = self.split_with_offsets(
                      array_ops_stack.stack([input_tensor])
                  )
                  return (
                      bytez.values,
                      start_offsets.values,
                      end_offsets.values,
                  )
              else:
                  # Our rank 1 tensor is the correct shape, so we can process it as
                  # normal.
                  return self._byte_split_with_offsets(input_tensor)
  
file_path: text/tensorflow_text/python/ops/byte_splitter.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensorflow.python.eager import monitoring
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops.ragged import ragged_conversion_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.ops.ragged.ragged_tensor import RaggedTensor
  from tensorflow_text.python.ops.tokenization import SplitterWithOffsets
  from tensorflow.python.framework import load_library
  from tensorflow.python.platform import resource_loader
label_desc: Use image node_id 3 for calling the ByteSplitter obj's underlying member method code with example usage: obj.split_with_offsets(input) and returns: input_tensor,  input_tensor,  input_tensor, input_tensor,  input_tensor,  input_tensor, self, bytez,  start_offsets,  end_offsets, self