code: def layer(
      geom=None,
      stat=None,
      data=None,
      mapping=None,
      position=None,
      **kwargs,
  ):
      """
      Create a new layer.
  
      Parameters
      ----------
      geom : str
          The geometric object to use to display the data.
      stat : str, default='identity'
          The statistical transformation to use on the data for this layer, as a string.
          Supported transformations: 'identity' (leaves the data unchanged),
          'count' (count number of points with same x-axis coordinate),
          'bin' (count number of points with x-axis coordinate in the same bin),
          'smooth' (perform smoothing - linear default),
          'density' (compute and draw kernel density estimate).
      data : dict or Pandas or Polars `DataFrame`
          The data to be displayed in this layer. If None, the default, the data
          is inherited from the plot data as specified in the call to ggplot.
      mapping : `FeatureSpec`
          Set of aesthetic mappings created by `aes()` function.
          Aesthetic mappings describe the way that variables in the data are
          mapped to plot "aesthetics".
      position : str or `FeatureSpec`
          Position adjustment, either as a string ('identity', 'stack', 'dodge', ...),
          or the result of a call to a position adjustment function.
      kwargs:
          Other arguments passed on to layer. These are often aesthetics settings, used to set an aesthetic to a fixed
          value, like color = "red", fill = "blue", size = 3 or shape = 21. They may also be parameters to the
          paired geom/stat.
  
      Returns
      -------
      `LayerSpec`
          Geom object specification.
  
      Notes
      -----
      A layer is a combination of data, stat and geom with a potential position adjustment. Usually layers are created
      using geom_* or stat_* calls but they can be created directly using this function.
  
      Examples
      --------
      .. jupyter-execute::
          :linenos:
          :emphasize-lines: 8
  
          import numpy as np
          from lets_plot import *
          LetsPlot.setup_html()
          n = 50
          np.random.seed(42)
          x = np.random.uniform(-1, 1, size=n)
          y = 25 * x ** 2 + np.random.normal(size=n)
          ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + layer(geom='point')
  
      """
      # todo: other parameters: inherit.aes = TRUE, subset = NULL, show.legend = NA
  
      return LayerSpec(**locals())
  
imports: import io
  import json
  import os
  from typing import Union
  from lets_plot._global_settings import get_global_bool, has_global_value, FRAGMENTS_ENABLED
label_desc: Use image node_id 2 for calling a global function with example usage: layer(geom, stat, data, mapping, position) and returns: LayerSpec