(layers)
Ensures that elements in a layer list are layers.

  Args:
    layers: A tuple or list whose elements can each be a layer, tuple, or list,
        and so on recursively.

  Returns:
    An analogous collection of layers in which embedded layer lists are
    wrapped in Serial layer instances.
Ensures that elements in a layer list are layers.
Ensures that elements in a layer list are layers .
def _ensure_sublayers(layers):
  """Ensures that elements in a layer list are layers.

  Args:
    layers: A tuple or list whose elements can each be a layer, tuple, or list,
        and so on recursively.

  Returns:
    An analogous collection of layers in which embedded layer lists are
    wrapped in Serial layer instances.
  """
  if not layers:  # None or an empty list can signal a no-op.
    return Serial(None)  # no-op, but still handles shapes and initialization
  elif isinstance(layers, (list, tuple)):
    sublayers_not_lists = []
    for layer in layers:
      sublayers_not_lists.append(
          Serial(layer) if isinstance(layer, (list, tuple)) else layer)
    return sublayers_not_lists
  else:
    raise TypeError(type(layers))
def _ensure_sublayers ( layers ) : if not layers : # None or an empty list can signal a no-op. return Serial ( None ) # no-op, but still handles shapes and initialization elif isinstance ( layers , ( list , tuple ) ) : sublayers_not_lists = [ ] for layer in layers : sublayers_not_lists . append ( Serial ( layer ) if isinstance ( layer , ( list , tuple ) ) else layer ) return sublayers_not_lists else : raise TypeError ( type ( layers ) )