code: def expand_dims(
      input: ragged_tensor.Ragged, axis, name=None
  ):  # pylint: disable=redefined-builtin
      """Inserts a dimension with shape 1 into a potentially ragged tensor's shape.
  
      Given a potentially ragged tenor `input`, this operation inserts a
      dimension with size 1 at the dimension `axis` of `input`'s shape.
  
      The following table gives some examples showing how `ragged.expand_dims`
      impacts the shapes of different input tensors.  Ragged dimensions are
      indicated by enclosing them in parentheses.
  
      input.shape             | axis | result.shape
      ----------------------- | ---- | -----------------------------
      `[D1, D2]`              |  `0` | `[1, D1, D2]`
      `[D1, D2]`              |  `1` | `[D1, 1, D2]`
      `[D1, D2]`              |  `2` | `[D1, D2, 1]`
      `[D1, (D2), (D3), D4]`  |  `0` | `[1, D1, (D2), (D3), D4]`
      `[D1, (D2), (D3), D4]`  |  `1` | `[D1, 1, (D2), (D3), D4]`
      `[D1, (D2), (D3), D4]`  |  `2` | `[D1, (D2), 1, (D3), D4]`
      `[D1, (D2), (D3), D4]`  |  `3` | `[D1, (D2), (D3), 1, D4]`
      `[D1, (D2), (D3), D4]`  |  `4` | `[D1, (D2), (D3), D4, 1]`
  
      Args:
        input: The potentially tensor that should be expanded with a new dimension.
        axis: An integer constant indicating where the new dimension should be
          inserted.
        name: A name for the operation (optional).
  
      Returns:
        A tensor with the same values as `input`, with an added dimension of
        size 1 at `axis`.
  
      #### Examples:
  
      >>> rt = tf.ragged.constant([[1, 2], [3]])
      >>> print(rt.shape)
      (2, None)
  
      >>> expanded = tf.expand_dims(rt, axis=0)
      >>> print(expanded.shape, expanded)
      (1, 2, None) <tf.RaggedTensor [[[1, 2], [3]]]>
  
      >>> expanded = tf.expand_dims(rt, axis=1)
      >>> print(expanded.shape, expanded)
      (2, 1, None) <tf.RaggedTensor [[[1, 2]], [[3]]]>
  
      >>> expanded = tf.expand_dims(rt, axis=2)
      >>> print(expanded.shape, expanded)
      (2, None, 1) <tf.RaggedTensor [[[1], [2]], [[3]]]>
      """
      with ops.name_scope(name, "RaggedExpandDims", [input]):
          input = ragged_tensor.convert_to_tensor_or_ragged_tensor(
              input, name="input"
          )
  
          if not ragged_tensor.is_ragged(input):
              return array_ops.expand_dims(input, axis)
  
          ndims = (
              None
              if input.shape.ndims is None
              else input.shape.ndims + 1
          )
          axis = array_ops.get_positive_axis(
              axis, ndims, ndims_name="rank(input)"
          )
  
          if axis == 0:
              return ragged_tensor.RaggedTensor.from_uniform_row_length(
                  input,
                  uniform_row_length=input.nrows(),
                  nrows=1,
                  validate=False,
              )
          elif axis == 1:
              return ragged_tensor.RaggedTensor.from_uniform_row_length(
                  input,
                  uniform_row_length=1,
                  nrows=input.nrows(),
                  validate=False,
              )
          else:
              if ragged_tensor.is_ragged(input.values):
                  return input.with_values(
                      expand_dims(input.values, axis - 1)
                  )
              else:
                  return input.with_values(
                      array_ops.expand_dims(input.values, axis - 1)
                  )
  
imports: from typing import Optional
  from typing import Union
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import check_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.ops import gen_ragged_array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import sort_ops
  from tensorflow.python.ops.ragged import dynamic_ragged_shape
  from tensorflow.python.ops.ragged import ragged_functional_ops
  from tensorflow.python.ops.ragged import ragged_math_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.ops.ragged import ragged_util
  from tensorflow.python.ops.ragged import segment_id_ops
  from tensorflow.python.types import core
  from tensorflow.python.util import dispatch
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 5 for calling a global function with example usage: expand_dims(input, axis, name) and returns: array_ops, ragged_tensor, ragged_tensor, input, input