Create a forward reference for a union or struct.
974134
def _create_type(self, env, item):
        """"""
        if item.name in env:
            existing_dt = env[item.name]
            raise InvalidSpec(
                'Symbol %s already defined (%s:%d).' %
                (quote(item.name), existing_dt._ast_node.path,
                 existing_dt._ast_node.lineno), item.lineno, item.path)
        namespace = self.api.ensure_namespace(env.namespace_name)
        if isinstance(item, AstStructDef):
            try:
                api_type = Struct(name=item.name, namespace=namespace,
                                  ast_node=item)
            except ParameterError as e:
                raise InvalidSpec(
                    'Bad declaration of %s: %s' % (quote(item.name), e.args[0]),
                    item.lineno, item.path)
        elif isinstance(item, AstUnionDef):
            api_type = Union(
                name=item.name, namespace=namespace, ast_node=item,
                closed=item.closed)
        else:
            raise AssertionError('Unknown type definition %r' % type(item))

        env[item.name] = api_type
        return api_type
1271657
def forwards(self, orm):
        ""
        orm['avocado.DataField'].objects.get_or_create(
            app_name='variants',
            model_name='variantphenotype',
            field_name='hgmd_id',
            defaults={
                'name': 'HGMD',
                'published': True
            })
292576
def forward(self, x: torch.Tensor, sublayer: Callable[[torch.Tensor], torch.Tensor]) -> torch.Tensor:
        """"""
        return x + self.dropout(sublayer(self.norm(x)))
727177
def structure(self, obj, cl):
        # type: (Any, Type[T]) -> T
        """"""

        return self._structure_func.dispatch(cl)(obj, cl)
1083771
def __sub_add_reference(self, key):
        """"""
        new_subs = self.__new_subs
        with new_subs:
            # don't allow multiple subscription requests to overwrite internal reference
            if key in new_subs:
                raise ValueError('subscription for given args pending: %s' % str(key))
            new_subs[key] = None
        try:
            yield
        except:
            # don't preserve reference if request creation failed
            with new_subs:
                new_subs.pop(key, None)
            raise
1161764
def proc_forward(etype, namespace: Dict[str, Any]):
    
    return etype._eval_type(namespace, namespace) if type(etype) is _ForwardRef else etype
1269309
def forward_all(collection)
      newcollection = collection.dup.clear
      collection.each do |point|
        newcollection << forward(point)
      end
      newcollection
    end
688323
def _forwardrefload(l: Loader, value: Any, type_: type) -> Any:
    
    if l.frefs is None:
        raise TypedloadException('ForwardRef resolving is disabled for the loader', value=value, type_=type_)
    tname = type_.__forward_arg__  # type: ignore
    t = l.frefs.get(tname)
    if t is None:
        raise TypedloadValueError(
            "ForwardRef '%s' unknown" % tname,
            value=value,
            type_=type_
        )
    return l.load(value, t, annotation=Annotation(AnnotationType.FORWARDREF, tname))
106848
@Override
    public Tensor forward() {
        Tensor x = modInX.getOutput();
        Tensor w = modInW.getOutput();
        y = new Tensor(x); // copy
        y.elemMultiply(w);
        return y;
    }
977182
def forwards(self, orm):
        ""
        for qde_xtf in orm['xtf.QualifiedDublinCoreElement'].objects.all().order_by('id'):
            qde = orm.QualifiedDublinCoreElement()
            qde.content = qde_xtf.content
            qde.term = qde_xtf.term
            qde.qualifier = qde_xtf.qualifier
            #import pdb;pdb.set_trace()
            c= orm['contenttypes.ContentType'].objects.get(pk=qde_xtf.content_type.pk)
            #c.name = qde_xtf.content_type.name
            #c.app_label = qde_xtf.content_type.app_label
            #c.model = qde_xtf.content_type.model
            qde.content_type = c
            #qde.content_type = qde_xtf.content_type
            qde.object_id = qde_xtf.object_id
            qde.save()
        for qdeh_xtf in  orm['xtf.QualifiedDublinCoreElementHistory'].objects.all().order_by('id'):
            qdeh = orm.QualifiedDublinCoreElementHistory()
            qdeh.content = qdeh_xtf.content
            qdeh.term = qdeh_xtf.term
            qdeh.qualifier = qdeh_xtf.qualifier
            c= orm['contenttypes.ContentType'].objects.get(pk=qdeh_xtf.content_type.pk)
            #c.name = qdeh_xtf.content_type.name
            #c.app_label = qdeh_xtf.content_type.app_label
            #c.model = qdeh_xtf.content_type.model
            qdeh.content_type = c
            #qdeh.content_type = qdeh_xtf.content_type
            qdeh.object_id = qdeh_xtf.object_id
            qdeh.qdce = orm['dublincore.QualifiedDublinCoreElement'].objects.get(pk=qdeh_xtf.qdce.pk)
            qdeh.qdce_id_stored = qdeh_xtf.qdce_id_stored
            qdeh.save()
233903
def _create_info_struct(file, mode, samplerate, channels,
                        format, subtype, endian):
    """"""
    original_format = format
    if format is None:
        format = _get_format_from_filename(file, mode)
        assert isinstance(format, (_unicode, str))
    else:
        _check_format(format)

    info = _ffi.new("SF_INFO*")
    if 'r' not in mode or format.upper() == 'RAW':
        if samplerate is None:
            raise TypeError("samplerate must be specified")
        info.samplerate = samplerate
        if channels is None:
            raise TypeError("channels must be specified")
        info.channels = channels
        info.format = _format_int(format, subtype, endian)
    else:
        if any(arg is not None for arg in (
                samplerate, channels, original_format, subtype, endian)):
            raise TypeError("Not allowed for existing files (except 'RAW'): "
                            "samplerate, channels, format, subtype, endian")
    return info
663952
def create(cls, domain, source, destinations):
        """"""
        cls.echo('Creating mail forward %s@%s' % (source, domain))
        options = {'destinations': list(destinations)}
        result = cls.call('domain.forward.create', domain, source, options)

        return result
101428
def _forward(self, x_dot_parameters):
        
        return forward(self._lattice, x_dot_parameters, 
                       self.state_machine.n_states)
1193728
def forwards(self, orm):
        ""
        # Project labels
        names = list(orm['samples.Project'].objects.values_list('label', flat=True))
        orm['samples.Cohort'].objects.filter(name__in=names).update(published=True)

        # World cohort
        orm['samples.Cohort'].objects.filter(name=DEFAULT_COHORT_NAME).update(published=True)
542403
def __struct_params_s(obj, separator=', ', f=repr, fmt='%s = %s'):
    """"""
    s = separator.join([__single_param(obj, n, f, fmt) for n in dir(obj) if __inc_param(obj, n)])
    return s
174438
def database_forwards(self, app_label, schema_editor, from_state, to_state):
        """"""
        Process = from_state.apps.get_model('flow', 'Process')  # pylint: disable=invalid-name

        # Validate process types to ensure consistency.
        errors = validate_process_types(Process.objects.all())
        if errors:
            raise ValueError("Process type consistency check failed after migration: {}".format(errors))
1008423
def _ConstructReference(cls, pairs=None, flat=None,
                        reference=None, serialized=None, urlsafe=None,
                        app=None, namespace=None, parent=None):
  """"""
  if cls is not Key:
    raise TypeError('Cannot construct Key reference on non-Key class; '
                    'received %r' % cls)
  if (bool(pairs) + bool(flat) + bool(reference) + bool(serialized) +
      bool(urlsafe)) != 1:
    raise TypeError('Cannot construct Key reference from incompatible keyword '
                    'arguments.')
  if flat or pairs:
    if flat:
      if len(flat) % 2:
        raise TypeError('_ConstructReference() must have an even number of '
                        'positional arguments.')
      pairs = [(flat[i], flat[i + 1]) for i in xrange(0, len(flat), 2)]
    elif parent is not None:
      pairs = list(pairs)
    if not pairs:
      raise TypeError('Key references must consist of at least one pair.')
    if parent is not None:
      if not isinstance(parent, Key):
        raise datastore_errors.BadValueError(
            'Expected Key instance, got %r' % parent)
      pairs[:0] = parent.pairs()
      if app:
        if app != parent.app():
          raise ValueError('Cannot specify a different app %r '
                           'than the parent app %r' %
                           (app, parent.app()))
      else:
        app = parent.app()
      if namespace is not None:
        if namespace != parent.namespace():
          raise ValueError('Cannot specify a different namespace %r '
                           'than the parent namespace %r' %
                           (namespace, parent.namespace()))
      else:
        namespace = parent.namespace()
    reference = _ReferenceFromPairs(pairs, app=app, namespace=namespace)
  else:
    if parent is not None:
      raise TypeError('Key reference cannot be constructed when the parent '
                      'argument is combined with either reference, serialized '
                      'or urlsafe arguments.')
    if urlsafe:
      serialized = _DecodeUrlSafe(urlsafe)
    if serialized:
      reference = _ReferenceFromSerialized(serialized)
    if not reference.path().element_size():
      raise RuntimeError('Key reference has no path or elements (%r, %r, %r).'
                         % (urlsafe, serialized, str(reference)))
    # TODO: ensure that each element has a type and either an id or a name
    if not serialized:
      reference = _ReferenceFromReference(reference)
    # You needn't specify app= or namespace= together with reference=,
    # serialized= or urlsafe=, but if you do, their values must match
    # what is already in the reference.
    if app is not None:
      ref_app = reference.app()
      if app != ref_app:
        raise RuntimeError('Key reference constructed uses a different app %r '
                           'than the one specified %r' %
                           (ref_app, app))
    if namespace is not None:
      ref_namespace = reference.name_space()
      if namespace != ref_namespace:
        raise RuntimeError('Key reference constructed uses a different '
                           'namespace %r than the one specified %r' %
                           (ref_namespace, namespace))
  return reference