code: def safely_reduce_dtype(ser):  # pandas.Series or numpy.array
      orig_dtype = "".join(
          [x for x in ser.dtype.name if x.isalpha()]
      )  # float/int
      mx = 1
      for val in ser.values:
          new_itemsize = np.min_scalar_type(val).itemsize
          if mx < new_itemsize:
              mx = new_itemsize
          if orig_dtype == "int":
              mx = max(mx, 4)
      new_dtype = orig_dtype + str(mx * 8)
      return ser.astype(new_dtype)
  
file_path: catalyst/catalyst/marketplace/utils/bundle_utils.py
imports: import os
  import random
  import re
  import shutil
  import bcolz
  import numpy
  import pandas
  from six import string_types
label_desc: Use image node_id 3 for calling a global function with example usage: safely_reduce_dtype(ser) and returns: ser