class_docstr: A class implements tf.keras.Model.
  
  Reference: https://arxiv.org/abs/1807.11626
class_docstr_tok: ["A","class","implements","tf.keras.Model",".","Reference",":","https",":","\/\/arxiv.org\/abs\/1807.11626"]
docstr: Builds a model.
docstr_tok: ["Builds","a","model","."]
code: def _build(self):
      """Builds a model."""
      self._blocks = []
  
      # Stem part.
      self._stem = Stem(
          self._global_params, self._blocks_args[0].input_filters
      )
  
      # Builds blocks.
      block_id = itertools.count(0)
      block_name = lambda: "blocks_%d" % next(block_id)
      for i, block_args in enumerate(self._blocks_args):
          assert block_args.num_repeat > 0
          assert block_args.super_pixel in [0, 1, 2]
          # Update block input and output filters based on depth multiplier.
          input_filters = round_filters(
              block_args.input_filters, self._global_params
          )
  
          output_filters = round_filters(
              block_args.output_filters, self._global_params
          )
          kernel_size = block_args.kernel_size
          if self._fix_head_stem and (
              i == 0 or i == len(self._blocks_args) - 1
          ):
              repeats = block_args.num_repeat
          else:
              repeats = round_repeats(
                  block_args.num_repeat, self._global_params
              )
          block_args = block_args._replace(
              input_filters=input_filters,
              output_filters=output_filters,
              num_repeat=repeats,
          )
  
          # The first block needs to take care of stride and filter size increase.
          conv_block = self._get_conv_block(block_args.conv_type)
          if not block_args.super_pixel:  #  no super_pixel at all
              self._blocks.append(
                  conv_block(
                      block_args, self._global_params, name=block_name()
                  )
              )
          else:
              # if superpixel, adjust filters, kernels, and strides.
              depth_factor = int(
                  4 / block_args.strides[0] / block_args.strides[1]
              )
              block_args = block_args._replace(
                  input_filters=block_args.input_filters * depth_factor,
                  output_filters=block_args.output_filters
                  * depth_factor,
                  kernel_size=(
                      (block_args.kernel_size + 1) // 2
                      if depth_factor > 1
                      else block_args.kernel_size
                  ),
              )
              # if the first block has stride-2 and super_pixel trandformation
              if (
                  block_args.strides[0] == 2
                  and block_args.strides[1] == 2
              ):
                  block_args = block_args._replace(strides=[1, 1])
                  self._blocks.append(
                      conv_block(
                          block_args,
                          self._global_params,
                          name=block_name(),
                      )
                  )
                  block_args = (
                      block_args._replace(  # sp stops at stride-2
                          super_pixel=0,
                          input_filters=input_filters,
                          output_filters=output_filters,
                          kernel_size=kernel_size,
                      )
                  )
              elif block_args.super_pixel == 1:
                  self._blocks.append(
                      conv_block(
                          block_args,
                          self._global_params,
                          name=block_name(),
                      )
                  )
                  block_args = block_args._replace(super_pixel=2)
              else:
                  self._blocks.append(
                      conv_block(
                          block_args,
                          self._global_params,
                          name=block_name(),
                      )
                  )
          if (
              block_args.num_repeat > 1
          ):  # rest of blocks with the same block_arg
              # pylint: disable=protected-access
              block_args = block_args._replace(
                  input_filters=block_args.output_filters,
                  strides=[1, 1],
              )
              # pylint: enable=protected-access
          for _ in xrange(block_args.num_repeat - 1):
              self._blocks.append(
                  conv_block(
                      block_args, self._global_params, name=block_name()
                  )
              )
  
      # Head part.
      self._head = Head(self._global_params)
  
imports: import collections
  import itertools
  import math
  from absl import logging
  import numpy
  import six
  from six.moves import xrange
  import tensorflow
  import utils
label_desc: Use image node_id 3 for calling the Model obj's underlying member method code with example usage: obj._build() without return types