def _safe_reshape(arr, new_shape):
if isinstance(arr, ABCSeries):<EOL><INDENT>arr = arr._values<EOL><DEDENT>if not isinstance(arr, ABCExtensionArray):<EOL><INDENT>arr = arr.reshape(new_shape)<EOL><DEDENT>return arr<EOL>
If possible, reshape `arr` to have shape `new_shape`,
with a couple of exceptions (see gh-13012):

1) If `arr` is a ExtensionArray or Index, `arr` will be
   returned as is.
2) If `arr` is a Series, the `_values` attribute will
   be reshaped and returned.

Parameters
----------
arr : array-like, object to be reshaped
new_shape : int or tuple of ints, the new shape