def normalize_attr_strings(a: np.ndarray) -> np.ndarray:
if np.issubdtype(a.dtype, np.object_):<EOL><INDENT>if np.all([(type(x) is str or type(x) is np.str_ or type(x) is np.unicode_) for x in a]):<EOL><INDENT>return np.array([x.encode('<STR_LIT:ascii>', '<STR_LIT>') for x in a])<EOL><DEDENT>elif np.all([type(x) is np.string_ for x in a]) or np.all([type(x) is np.bytes_ for x in a]):<EOL><INDENT>return a.astype("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>logging.debug(f"<STR_LIT>")<EOL>return np.array([str(x) for x in a], dtype="<STR_LIT>")<EOL><DEDENT><DEDENT>elif np.issubdtype(a.dtype, np.string_) or np.issubdtype(a.dtype, np.object_):<EOL><INDENT>return a<EOL><DEDENT>elif np.issubdtype(a.dtype, np.str_) or np.issubdtype(a.dtype, np.unicode_):<EOL><INDENT>return np.array([x.encode('<STR_LIT:ascii>', '<STR_LIT>') for x in a])<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
Take an np.ndarray of all kinds of string-like elements, and return an array of ascii (np.string_) objects