def METHOD_NAME(encoding, rank=None):
    if isinstance(encoding, np.ndarray):
        sparse_indices = encoding
    elif isinstance(encoding, enc.Encoding):
        sparse_indices = encoding.sparse_indices
    else:
        raise ValueError(
            'encoding must be np.ndarray or Encoding, got %s' % str(encoding))
    _assert_sparse_rank(sparse_indices, 3)
    return sparse_indices