code: def normalize_index(index):
      
      index = np.asarray(index)
      
      if len(index) == 0:
          return index.astype('int')
      
      if index.dtype == 'bool':
          index = index.nonzero()[0]
      elif index.dtype == 'int':
          pass
      else:
          raise ValueError('Index should be either integer or bool')
      return index
docs: normalize numpy index