docstr: Test that Layer regularizers can reference data created in loops.
docstr_tok: ["Test","that","Layer","regularizers","can","reference","data","created","in","loops","."]
code: def testUsingInfeedQueueWithRegularizer(self):
      """Test that Layer regularizers can reference data created in loops."""
  
      with ops.Graph().as_default():
  
          def make_regularizer(scale):
              def regularizer(inputs):
                  return scale * math_ops.reduce_sum(
                      math_ops.square(inputs)
                  )
  
              return regularizer
  
          def training_step(inputs, scale):
              outputs = convolutional.conv2d(
                  inputs,
                  filters=16,
                  kernel_size=(3, 3),
                  data_format="channels_first",
                  kernel_regularizer=make_regularizer(scale),
              )
              loss = math_ops.reduce_mean(math_ops.square(outputs))
              return loss.op
  
          inputs = array_ops.zeros(shape=(128, 32, 32, 16))
          scale = array_ops.ones(shape=())
          infeed = tpu_feed.InfeedQueue(
              tuple_types=[dtypes.float32, dtypes.float32],
              tuple_shapes=[inputs.shape, scale.shape],
          )
  
          def loop():
              return training_loop.repeat(
                  5, training_step, infeed_queue=infeed
              )
  
          # This should not throw an error.
          tpu.rewrite(loop)
  
imports: 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 importer
  from tensorflow.python.framework import ops
  from tensorflow.python.layers import convolutional
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import special_math_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.platform import test
  from tensorflow.python.tpu import tpu
  from tensorflow.python.tpu import tpu_feed
  from tensorflow.python.tpu import tpu_replication
  from tensorflow.python.tpu import training_loop
  from tensorflow.python.tpu.ops import tpu_ops
label_desc: Use image node_id 1 for calling the TPULayerRewriteTest obj's underlying member method code with example usage: obj.testUsingInfeedQueueWithRegularizer() and returns: regularizer, loss, training_loop, unknown