<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _instruction_getter(self, name, env_replace):
 """ Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance """

        if name != 'LABEL' and name != 'ENV':
            raise ValueError("Unsupported instruction '%s'", name)
        instructions = {}
        envs = {}

        for instruction_desc in self.structure:
            this_instruction = instruction_desc['instruction']
            if this_instruction == 'FROM':
                instructions.clear()
                envs = self.parent_env.copy()
            elif this_instruction in (name, 'ENV'):
                logger.debug("%s value: %r", name.lower(), instruction_desc['value'])
                key_val_list = extract_labels_or_envs(env_replace=env_replace,
                                                      envs=envs,
                                                      instruction_value=instruction_desc['value'])
                for key, value in key_val_list:
                    if this_instruction == name:
                        instructions[key] = value
                        logger.debug("new %s %r=%r", name.lower(), key, value)
                    if this_instruction == 'ENV':
                        envs[key] = value

        logger.debug("instructions: %r", instructions)
        return Labels(instructions, self) if name == 'LABEL' else Envs(instructions, self)