code: def add_gen_flag(
      data_feature, data_gen_flag, data_feature_outputs, sample_len
  ):
      from bigdl.nano.utils.common import invalidInputError
  
      for output in data_feature_outputs:
          if output.is_gen_flag:
              invalidInputError(
                  False,
                  "is_gen_flag should be False for all feature_outputs",
              )
  
      if data_feature.shape[2] != np.sum(
          [t.dim for t in data_feature_outputs]
      ):
          invalidInputError(
              False, "feature dimension does not match feature_outputs"
          )
  
      if len(data_gen_flag.shape) != 2:
          invalidInputError(
              False, "data_gen_flag should be 2 dimension"
          )
  
      num_sample, length = data_gen_flag.shape
  
      data_gen_flag = np.expand_dims(data_gen_flag, 2)
  
      data_feature_outputs.append(
          Output(type_=OutputType.DISCRETE, dim=2, is_gen_flag=True)
      )
  
      shift_gen_flag = np.concatenate(
          [
              data_gen_flag[:, 1:, :],
              np.zeros((data_gen_flag.shape[0], 1, 1)),
          ],
          axis=1,
      )
      if length % sample_len != 0:
          invalidInputError(
              False, "length must be a multiple of sample_len"
          )
      data_gen_flag_t = np.reshape(
          data_gen_flag,
          [num_sample, int(length / sample_len), sample_len],
      )
      data_gen_flag_t = np.sum(data_gen_flag_t, 2)
      data_gen_flag_t = data_gen_flag_t > 0.5
      data_gen_flag_t = np.repeat(data_gen_flag_t, sample_len, axis=1)
      data_gen_flag_t = np.expand_dims(data_gen_flag_t, 2)
      data_feature = np.concatenate(
          [
              data_feature,
              shift_gen_flag,
              (1 - shift_gen_flag) * data_gen_flag_t,
          ],
          axis=2,
      )
  
      return data_feature, data_feature_outputs
  
file_path: BigDL/python/chronos/src/bigdl/chronos/simulator/doppelganger/util.py
imports: from .output import OutputType, Output, Normalization
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: add_gen_flag(data_feature, data_gen_flag, data_feature_outputs, sample_len) and returns: data_feature,  data_feature_outputs