docstr: Overdetermined case with randomly chosen linear model.
  
  Hard to predict the argmin, but can check its expected performance.
docstr_tok: ["Overdetermined","case","with","randomly","chosen","linear","model",".","Hard","to","predict","the","argmin",",","but","can","check","its","expected","performance","."]
code: def test_randomized(self):
      """Overdetermined case with randomly chosen linear model.
  
      Hard to predict the argmin, but can check its expected performance.
      """
      np.random.seed(0)
      nblocks = 10
      blocks_to_use = np.arange(1, nblocks + 1)
      depth = 10
      ntrials = 2 * nblocks * depth
      architectures = np.random.randint(
          1, nblocks + 1, size=(ntrials, depth)
      )
  
      # For chosen w, compute b such that all losses are positive.
      w = np.random.normal(size=(depth, nblocks))
      # Index arch-1 is because we had to avoid using the empty zero block,
      # because LinearModel will trim it, but we want to use block as index.
      losses = [
          np.sum(w[np.arange(depth), arch - 1])
          for arch in architectures
      ]
      b = -np.amin(losses) + 0.001
      losses_positive = losses + b
  
      best = _get_suggestion(
          architectures, blocks_to_use, losses_positive
      )
      self.assertLen(best, depth)
      loss_by_model = np.sum(w[np.arange(depth), best - 1]) + b
      self.assertTrue(np.all(losses_positive >= loss_by_model))
  
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 5 for calling the LinearModelTest obj's underlying member method code with example usage: obj.test_randomized() without return types