code: def test_create_estimator_with_misspecified_args(self, loss_key):
      hparams = _get_hparams(loss_key)
      with self.assertRaises(ValueError):
          _ = tfr_estimator.EstimatorBuilder(
              _context_feature_columns,
              None,  # `document_feature_columns` is None.
              _scoring_function,
              hparams=hparams,
          )
  
      with self.assertRaises(ValueError):
          _ = tfr_estimator.EstimatorBuilder(
              _context_feature_columns,
              _example_feature_columns,
              None,  # `scoring_function` is None.
              hparams=hparams,
          )
  
      # Either the optimizer or the hparams["learning_rate"] should be specified.
      del hparams["learning_rate"]
      with self.assertRaises(ValueError):
          _ = tfr_estimator.EstimatorBuilder(
              _context_feature_columns,
              _example_feature_columns,
              _scoring_function,
              optimizer=None,
              hparams=hparams,
          )
  
      # Passing an optimizer (no hparams["learning_rate"]) will slience the error.
      pip = tfr_estimator.EstimatorBuilder(
          _context_feature_columns,
          _example_feature_columns,
          _scoring_function,
          optimizer=tf.compat.v1.train.AdamOptimizer(
              learning_rate=0.01
          ),
          hparams=_get_hparams(loss_key),
      )
      self.assertIsInstance(pip, tfr_estimator.EstimatorBuilder)
  
      # Adding "learning_rate" to hparams (no optimizer) also silences the errors.
      hparams.update(learning_rate=0.01)
      pip = tfr_estimator.EstimatorBuilder(
          _context_feature_columns,
          _example_feature_columns,
          _scoring_function,
          optimizer=None,
          hparams=_get_hparams(loss_key),
      )
      self.assertIsInstance(pip, tfr_estimator.EstimatorBuilder)
  
imports: import os
  from absl.testing import parameterized
  import six
  import tensorflow
  from tensorflow import estimator
  from google.protobuf import text_format
  from tensorflow_ranking.python import data
  from tensorflow_ranking.python import estimator
  from tensorflow_ranking.python import feature
  from tensorflow_serving.apis import input_pb2
label_desc: Use image node_id 3 for calling the EstimatorBuilderTest obj's underlying member method code with example usage: obj.test_create_estimator_with_misspecified_args(loss_key) without return types