docstr: Ensure that we correctly deal with the flatten block in fitting.
  
  1) Flatten blocks won't be in spec.blocks_to_use, even though
     the trial architectures loaded from filesystem will contain them.
  
  2) The model shouldn't try to place a flatten block, since there is only
     one valid position at the convolutional -> dense transition.
docstr_tok: ["Ensure","that","we","correctly","deal","with","the","flatten","block","in","fitting",".","1",")","Flatten","blocks","wo","n't","be","in","spec.blocks_to_use",",","even","though","the","trial","architectures","loaded","from","filesystem","will","contain","them",".","2",")","The","model","should","n't","try","to","place","a","flatten","block",",","since","there","is","only","one","valid","position","at","the","convolutional","-",">","dense","transition","."]
code: def test_flatten_modelfitting(self):
      """Ensure that we correctly deal with the flatten block in fitting.
  
      1) Flatten blocks won't be in spec.blocks_to_use, even though
         the trial architectures loaded from filesystem will contain them.
  
      2) The model shouldn't try to place a flatten block, since there is only
         one valid position at the convolutional -> dense transition.
      """
  
      blocks_to_use = np.arange(4)
      depth = 3
      ntrials = 10 * len(blocks_to_use) * depth
      flatten_blocks = (
          block_builder.BlockType.FLATTEN,
          block_builder.BlockType.DOWNSAMPLE_FLATTEN,
          block_builder.BlockType.PLATE_REDUCTION_FLATTEN,
      )
      assert not set(b.value for b in flatten_blocks) & set(
          blocks_to_use
      )
  
      # Generate architectures that contain a flatten block.
      def random_arch():
          depth = np.random.randint(2, 5)
          arch = list(np.random.choice(blocks_to_use, size=depth))
          if np.random.choice([True, False]):
              flatten_loc = np.random.randint(depth)
              flatten_type = np.random.choice(flatten_blocks)
              arch.insert(flatten_loc, flatten_type)
          return np.array(arch)
  
      np.random.seed(0)
      architectures = [random_arch() for _ in range(ntrials)]
      losses = np.random.uniform(0.1, 1, size=ntrials)
  
      # Since flatten isn't in the spec blocks_to_use, the one-hot converter
      # will raise a ValueError unless we filter it out correctly.
      # We don't care what the linear model suggests; we only care that
      # it doesn't choke on the flatten block that's not in blocks_to_use
      try:
          _ = _get_suggestion(architectures, blocks_to_use, losses)
      except ValueError:
          self.fail("LinearModel failed to ignore flatten block")
  
imports: from absl.testing import parameterized
  import mock
  from model_search import block_builder
  from model_search import hparam
  from model_search.metadata import trial
  from model_search.proto import phoenix_spec_pb2
  from model_search.search import linear_model
  from model_search.search import test_utils
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 9 for calling the LinearModelTest obj's underlying member method code with example usage: obj.test_flatten_modelfitting() and returns: np