class_docstr: This is an abstract base class.
  Don't inherit from unittest.TestCase, and don't name it 'Test*'.
  Do, however, do these things in classes which inherit from this.
code: def _createDense(self, dtype=core.DataType.FLOAT):
      perfect_model = np.array([2, 6, 5, 0, 1]).astype(np.float32)
      np.random.seed(123)  # make test deterministic
      numpy_dtype = (
          np.float32 if dtype == core.DataType.FLOAT else np.float16
      )
      initializer = (
          Initializer
          if dtype == core.DataType.FLOAT
          else PseudoFP16Initializer
      )
      data = np.random.randint(2, size=(20, perfect_model.size)).astype(
          numpy_dtype
      )
      label = np.dot(data, perfect_model)[:, np.newaxis]
  
      model = ModelHelper(name="test", arg_scope={"order": "NCHW"})
      out = brew.fc(
          model,
          "data",
          "fc",
          perfect_model.size,
          1,
          ("ConstantFill", {}),
          ("ConstantFill", {}),
          axis=0,
          WeightInitializer=initializer,
          BiasInitializer=initializer,
      )
      if dtype == core.DataType.FLOAT16:
          out = model.HalfToFloat(out, out + "_fp32")
      sq = model.SquaredL2Distance([out, "label"])
      loss = model.AveragedLoss(sq, "avg_loss")
      grad_map = model.AddGradientOperators([loss])
      self.assertIsInstance(grad_map["fc_w"], core.BlobReference)
      return (model, perfect_model, data, label)
  
file_path: pytorch/caffe2/python/optimizer_test_util.py
imports: import unittest
  import numpy
  from caffe2.python import brew, core, workspace, cnn, optimizer
  from caffe2.python.modeling.initializers import Initializer, PseudoFP16Initializer
  from caffe2.python.model_helper import ModelHelper
label_desc: Use image node_id 1 for calling the OptimizerTestBase obj's underlying member method code with example usage: obj._createDense(dtype) and returns: model,  perfect_model,  data,  label