parameters: (items, expected_type=None)
return_statement: return expected_type
docstring: r"""Asserts all items are of the same base type.
  
    Args:
      items: List of graph items (e.g., `Variable`, `Tensor`, `SparseTensor`,
          `Operation`, or `IndexedSlices`). Can include `None` elements, which
          will be ignored.
      expected_type: Expected type. If not specified, assert all items are
          of the same base type.
  
    Returns:
      Validated type, or none if neither expected_type nor items provided.
  
    Raises:
      ValueError: If any types do not match.
docstring_summary: r"""Asserts all items are of the same base type.
docstring_tokens: r Asserts all items are of the same base type .
function: def _assert_same_base_type(items, expected_type=None):
    r"""Asserts all items are of the same base type.
  
    Args:
      items: List of graph items (e.g., `Variable`, `Tensor`, `SparseTensor`,
          `Operation`, or `IndexedSlices`). Can include `None` elements, which
          will be ignored.
      expected_type: Expected type. If not specified, assert all items are
          of the same base type.
  
    Returns:
      Validated type, or none if neither expected_type nor items provided.
  
    Raises:
      ValueError: If any types do not match.
    """
    original_item_str = None
    for item in items:
      if item is not None:
        item_type = item.dtype.base_dtype
        if not expected_type:
          expected_type = item_type
          original_item_str = item.name if hasattr(item, 'name') else str(item)
        elif expected_type != item_type:
          raise ValueError('%s, type=%s, must be of the same type (%s)%s.' % (
              item.name if hasattr(item, 'name') else str(item),
              item_type, expected_type,
              (' as %s' % original_item_str) if original_item_str else ''))
    return expected_type
function_tokens: def _assert_same_base_type ( items , expected_type = None ) : original_item_str = None for item in items : if item is not None : item_type = item . dtype . base_dtype if not expected_type : expected_type = item_type original_item_str = item . name if hasattr ( item , 'name' ) else str ( item ) elif expected_type != item_type : raise ValueError ( '%s, type=%s, must be of the same type (%s)%s.' % ( item . name if hasattr ( item , 'name' ) else str ( item ) , item_type , expected_type , ( ' as %s' % original_item_str ) if original_item_str else '' ) ) return expected_type