code: def _testTypesForFtrlMultiplyLinearByLr(
      self,
      x,
      y,
      z,
      lr,
      grad,
      use_gpu=None,
      l1=0.0,
      l2=0.0,
      lr_power=-0.5,
  ):
      self.setUp()
      with self.session(use_gpu=use_gpu):
          var = variable_v1.VariableV1(x)
          accum = variable_v1.VariableV1(y)
          linear = variable_v1.VariableV1(z)
          self.evaluate(variables.global_variables_initializer())
  
          self.assertAllCloseAccordingToType(x, self.evaluate(var))
          apply_ftrl = gen_training_ops.apply_ftrl(
              var,
              accum,
              linear,
              grad,
              lr,
              l1,
              l2,
              lr_power,
              multiply_linear_by_lr=True,
          )
          out = self.evaluate(apply_ftrl)
          self.assertShapeEqual(out, apply_ftrl)
          accum_update = y + grad * grad
          linear_update = (
              z
              + grad * lr
              - (accum_update ** (-lr_power) - y ** (-lr_power)) * x
          )
          quadratic = accum_update ** (-lr_power) + 2 * l2 * lr
          expected_out = np.array(
              [
                  (
                      np.sign(linear_update[i]) * l1 * lr
                      - linear_update[i]
                  )
                  / (quadratic[i])
                  if np.abs(linear_update[i]) > l1 * lr
                  else 0.0
                  for i in range(linear_update.size)
              ]
          )
          self.assertAllCloseAccordingToType(
              accum_update, self.evaluate(accum)
          )
          if x.dtype == np.float16:
              # The calculations here really are not very precise in float16.
              self.assertAllClose(
                  linear_update,
                  self.evaluate(linear),
                  rtol=2e-2,
                  atol=2e-2,
              )
              self.assertAllClose(
                  expected_out, out, rtol=2e-2, atol=2e-2
              )
          elif x.dtype == np.float32:
              # The calculations here not sufficiently precise in float32.
              self.assertAllClose(
                  linear_update,
                  self.evaluate(linear),
                  rtol=1e-5,
                  atol=1e-5,
              )
              self.assertAllClose(
                  expected_out, out, rtol=1e-5, atol=1e-5
              )
          else:
              self.assertAllClose(linear_update, self.evaluate(linear))
              self.assertAllClose(expected_out, out)
  
imports: import itertools
  import threading
  import numpy
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.framework.test_util import TensorFlowTestCase
  from tensorflow.python.ops import gen_training_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 6 for calling the TrainingOpsTest obj's underlying member method code with example usage: obj._testTypesForFtrlMultiplyLinearByLr(x, y, z, lr, grad, use_gpu, l1, l2, lr_power) without return types