code: def encode_features(X, enc_map=None):
      """Converts categorical values in each column of X to integers in the range
      [0, n_unique_values_in_column - 1].
  
      If mapping is not provided, it is calculated based on the values in X.
  
      Unknown values during prediction get a value of -1.
      """
      if enc_map is None:
          fit = True
          # We will calculate enc_map, so initialize the list of column mappings.
          enc_map = []
      else:
          fit = False
  
      Xenc = np.zeros(X.shape, dtype="int32")
      for ii in range(X.shape[1]):
          if fit:
              col_enc = {
                  val: jj for jj, val in enumerate(np.unique(X[:, ii]))
              }
              enc_map.append(col_enc)
          # Unknown categories all get a value of -1.
          Xenc[:, ii] = np.array(
              [enc_map[ii].get(x, -1) for x in X[:, ii]]
          )
  
      return Xenc, enc_map
  
imports: import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: encode_features(X, enc_map) and returns: Xenc,  enc_map