class_docstr: Locally-connected layer for 1D inputs.
  
  The LocallyConnected1d layer applies a different set of filters to each patch
  of the input. This is similar to applying a convolution layer, except that
  locally-connected layer uses a different set of weights for each patch.
  
  The size of patch is determined by the kernel size. The stride is currently
  not modifiable and set to one. This means for the input of shape (..., L, D)
  the output shape for paddings 'SAME' and 'WRAP' will be (..., L, filters) and
  for padding 'VALID' (..., L-kernel_size+1, filters); where L is the number of
  "pixels" or "steps" in the input, D is the size of the embedding.
  
  Note that, since the weights for different patches are not shared, the number
  of "pixels" or "steps" cannot change after calling init_weights_and_state.
  This is because each "pixel" is assigned its own set of weights.
class_docstr_tok: ["Locally-connected","layer","for","1D","inputs",".","The","LocallyConnected1d","layer","applies","a","different","set","of","filters","to","each","patch","of","the","input",".","This","is","similar","to","applying","a","convolution","layer",",","except","that","locally-connected","layer","uses","a","different","set","of","weights","for","each","patch",".","The","size","of","patch","is","determined","by","the","kernel","size",".","The","stride","is","currently","not","modifiable","and","set","to","one",".","This","means","for","the","input","of","shape","(","...",",","L",",","D",")","the","output","shape","for","paddings","'SAME","'","and","'WRAP","'","will","be","(","...",",","L",",","filters",")","and","for","padding","'VALID","'","(","...",",","L-kernel_size+1",",","filters",")",";","where","L","is","the","number","of","''","pixels","''","or","``","steps","''","in","the","input",",","D","is","the","size","of","the","embedding",".","Note","that",",","since","the","weights","for","different","patches","are","not","shared",",","the","number","of","``","pixels","''","or","``","steps","''","can","not","change","after","calling","init_weights_and_state",".","This","is","because","each","``","pixel","''","is","assigned","its","own","set","of","weights","."]
docstr: Randomly initializes this layer's weights.
  
  Weights are a `(w, b)` tuple for layers created with `use_bias=True` (the
  default case), or a `w` tensor for layers created with `use_bias=False`.
  
  Args:
    input_signature: `ShapeDtype` instance characterizing the input this layer
        should compute on.
docstr_tok: ["Randomly","initializes","this","layer","'s","weights",".","Weights","are","a","`","(","w",",","b",")","`","tuple","for","layers","created","with","`","use_bias=True","`","(","the","default","case",")",",","or","a","`","w","`","tensor","for","layers","created","with","`","use_bias=False","`",".","Args",":","input_signature",":","`","ShapeDtype","`","instance","characterizing","the","input","this","layer","should","compute","on","."]
code: def init_weights_and_state(self, input_signature):
      """Randomly initializes this layer's weights.
  
      Weights are a `(w, b)` tuple for layers created with `use_bias=True` (the
      default case), or a `w` tensor for layers created with `use_bias=False`.
  
      Args:
        input_signature: `ShapeDtype` instance characterizing the input this layer
            should compute on.
      """
      shape_w = (
          input_signature.shape[-2],
          self._kernel_size,
          input_signature.shape[-1],
          self._filters,
      )
      if self._padding == "VALID":
          shape_b = (
              input_signature.shape[-2] - self._kernel_size + 1,
              self._filters,
          )
      else:
          shape_b = (
              input_signature.shape[-2],
              self._filters,
          )
  
      rng_w, rng_b = fastmath.random.split(self.rng, 2)
      w = self._kernel_initializer(
          shape_w, rng_w, nonreceptive_dims=[0]
      )
  
      if self._use_bias:
          b = self._bias_initializer(shape_b, rng_b)
          self.weights = (w, b)
      else:
          self.weights = w
  
imports: from absl import logging
  import numpy
  import tensorflow
  from trax import fastmath
  from trax.fastmath import numpy
  from trax.layers import base
  from trax.layers import initializers
  from trax.layers.assert_shape import assert_shape
  from trax.layers.base import Fn
label_desc: Use image node_id 3 for calling the LocallyConnected1d obj's underlying member method code with example usage: obj.init_weights_and_state(input_signature) without return types