class_docstr: Mixes several tensors by a learned weighting.
  
  Computes a parameterised scalar mixture of N tensors.
  This method was proposed by Liu et al. (2019) in the paper:
  "Linguistic Knowledge and Transferability of Contextual Representations" (https://arxiv.org/abs/1903.08855)
  
  The implementation is copied and slightly modified from the allennlp repository and is licensed under Apache 2.0.
  It can be found under:
  https://github.com/allenai/allennlp/blob/master/allennlp/modules/scalar_mix.py.
docstr: Forward pass of scalar mix.
  
  Computes a weighted average of the ``tensors``.  The input tensors an be any shape
  with at least two dimensions, but must all be the same shape.
  
  Args:
      tensors: list of input tensors
  
  Returns: computed weighted average of input tensors
docstr_tok: ["Forward","pass","of","scalar","mix",".","Computes","a","weighted","average","of","the","``","tensors","``",".","The","input","tensors","an","be","any","shape","with","at","least","two","dimensions",",","but","must","all","be","the","same","shape",".","Args",":","tensors",":","list","of","input","tensors","Returns",":","computed","weighted","average","of","input","tensors"]
code: def forward(self, tensors: List[torch.Tensor]) -> torch.Tensor:
      """Forward pass of scalar mix.
  
      Computes a weighted average of the ``tensors``.  The input tensors an be any shape
      with at least two dimensions, but must all be the same shape.
  
      Args:
          tensors: list of input tensors
  
      Returns: computed weighted average of input tensors
      """
      if len(tensors) != self.mixture_size:
          log.error(
              "{} tensors were passed, but the module was initialized to mix {} tensors.".format(
                  len(tensors), self.mixture_size
              )
          )
  
      normed_weights = torch.nn.functional.softmax(
          torch.cat(list(self.scalar_parameters)), dim=0
      )
      normed_weights_split = torch.split(
          normed_weights, split_size_or_sections=1
      )
  
      pieces = []
      for weight, tensor in zip(normed_weights_split, tensors):
          pieces.append(weight * tensor)
      return self.gamma * sum(pieces)
  
imports: import inspect
  import logging
  from abc import abstractmethod
  from typing import Any, Dict, Generic, List, Sequence, Type, Union
  import torch
  from torch.nn import Parameter, ParameterList
  import flair
  from flair.data import DT, Sentence
label_desc: Use image node_id 2 for calling the ScalarMix obj's underlying member method code with example usage: obj.forward(tensors) and returns: unknown