in src/sagemaker_huggingface_inference_toolkit/decoder_encoder.py [0:0]
def _array_to_npy(array_like, accept_type=None):
"""Convert an array-like object to the NPY format.
To understand better what an array-like object is see:
https://docs.scipy.org/doc/numpy/user/basics.creation.html#converting-python-array-like-objects-to-numpy-arrays
Args:
array_like (np.array or Iterable or int or float): array-like object
to be converted to NPY.
Returns:
(obj): NPY array.
"""
buffer = BytesIO()
np.save(buffer, array_like)
return buffer.getvalue()