code: def mutate_replace(architecture, new_block):
      """Replaces one random block with the chosen new block.
  
      Returns a copy; input is not modified. The element to replace is chosen
      uniformly at random. Special care is taken not to replace the FLATTEN block.
  
      Args:
        architecture: An np.ndarray of integers corresponding to BlockType enum.
        new_block: Integer value of the desired BlockType to insert.
  
      Returns:
        An np.array of the architecture containing the new block.
      """
      output_architecture = architecture.copy()
      while True:
          block_to_replace = np.random.randint(0, architecture.size)
          blocktype = block_builder.BlockType(
              output_architecture[block_to_replace]
          )
          if blocktype not in block_builder.FLATTEN_TYPES:
              break
      output_architecture[block_to_replace] = new_block
      return output_architecture
  
file_path: model_search/model_search/search/common.py
imports: import os
  from model_search import block_builder
  from model_search.architecture import architecture_utils
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 8 for calling a global function with example usage: mutate_replace(architecture, new_block) and returns: output_architecture