# biome.text.modules.configuration.defs Module

# ComponentConfiguration Class


class ComponentConfiguration (*args, **kwds)

The layer spec component allows create Pytorch modules lazily, and instantiate them inside a context (Model or other component) dimension layer chain.

The layer spec wraps a component params and will generate an instance of type T once the input_dim is set.

# Ancestors

  • typing.Generic
  • allennlp.common.from_params.FromParams

# Subclasses

# from_params Static method


def from_params (
  params: allennlp.common.params.Params,
  **extras,
)  -> ~T

This is the automatic implementation of from_params. Any class that subclasses FromParams (or Registrable, which itself subclasses FromParams) gets this implementation for free. If you want your class to be instantiated from params in the "obvious" way – pop off parameters and hand them to your constructor with the same names – this provides that functionality.

If you need more complex logic in your from from_params method, you'll have to implement your own method that overrides this one.

The constructor_to_call and constructor_to_inspect arguments deal with a bit of redirection that we do. We allow you to register particular @classmethods on a class as the constructor to use for a registered name. This lets you, e.g., have a single Vocabulary class that can be constructed in two different ways, with different names registered to each constructor. In order to handle this, we need to know not just the class we're trying to construct (cls), but also what method we should inspect to find its arguments (constructor_to_inspect), and what method to call when we're done constructing arguments (constructor_to_call). These two methods are the same when you've used a @classmethod as your constructor, but they are different when you use the default constructor (because you inspect __init__, but call cls()).

# Instance variables

var config : Dict[str, Any]

Component read-only configuration

# input_dim Method


def input_dim (
  self,
  input_dim: int,
)  -> ComponentConfiguration

Sets the input dimension attribute for this layer configuration

# compile Method


def compile (
  self,
  **extras,
)  -> ~T

Using the wrapped configuration and the input dimension, generates a instance of type T representing the layer configuration

Maintained by