Returns a Loss instance.

    :param config: Loss configuration.
    :return: Instance implementing Loss.
181532
def get_length_task_loss(config: LossConfig) -> 'Loss':
    
    if config.length_task_link is not None:
        if config.length_task_link == C.LINK_NORMAL:
            return MSELoss(config,
                           output_names=[C.LENRATIO_OUTPUT_NAME],
                           label_names=[C.LENRATIO_LABEL_NAME])
        elif config.length_task_link == C.LINK_POISSON:
            return PoissonLoss(config,
                               output_names=[C.LENRATIO_OUTPUT_NAME],
                               label_names=[C.LENRATIO_LABEL_NAME])
        else:
            raise ValueError("unknown link function name for length task: %s" % config.length_task_link)
    return None
50864
def _get_config_instance(group_or_term, session, **kwargs):
    
    path = group_or_term._get_path()
    cached = group_or_term._top._cached_configs.get(path)
    if cached:
        config = cached
        created = False
    else:
        # does not exist or not yet cached
        config, created = get_or_create(session, Config, **kwargs)
    return config, created
1365438
def _get_config(self, host, port, unix_socket, auth, config_key):
        

        client = self._client(host, port, unix_socket, auth)
        if client is None:
            return None

        config_value = client.config_get(config_key)
        del client
        return config_value
311863
async def set_config(self, config):
        
        config_facade = client.ModelConfigFacade.from_connection(
            self.connection()
        )
        for key, value in config.items():
            if isinstance(value, ConfigValue):
                config[key] = value.value
        await config_facade.ModelSet(config)
887361
def client_socket(self, config):
		
		if self.__client_socket is None:
			self.__client_socket = self.create_client_socket(config)
		return self.__client_socket
552124
def from_dict(config):
        '''
        
        '''
        return ProxyConfig(
            http=config.get('httpProxy'),
            https=config.get('httpsProxy'),
            ftp=config.get('ftpProxy'),
            no_proxy=config.get('noProxy'),
        )
87102
def _get_config(self, section: str, key: str, fallback: str=object()) -> str:
        
        return self._config.get(section, key, fallback=fallback)
694614
def zero_one_loss_calc(TP, POP):
    
    try:
        length = POP
        return (length - sum(TP.values()))
    except Exception:
        return "None"
789114
def loss_batch(model:nn.Module, xb:Tensor, yb:Tensor, loss_func:OptLossFunc=None, opt:OptOptimizer=None,
               cb_handler:Optional[CallbackHandler]=None)->Tuple[Union[Tensor,int,float,str]]:
    ""
    cb_handler = ifnone(cb_handler, CallbackHandler())
    if not is_listy(xb): xb = [xb]
    if not is_listy(yb): yb = [yb]
    out = model(*xb)
    out = cb_handler.on_loss_begin(out)

    if not loss_func: return to_detach(out), yb[0].detach()
    loss = loss_func(out, *yb)

    if opt is not None:
        loss,skip_bwd = cb_handler.on_backward_begin(loss)
        if not skip_bwd:                     loss.backward()
        if not cb_handler.on_backward_end(): opt.step()
        if not cb_handler.on_step_end():     opt.zero_grad()

    return loss.detach().cpu()
574475
def get_config():
    
    configpath = get_configpath()
    if not configpath.exists():
        raise IOError("Config file {} not found.".format(str(configpath)))
    else:
        config = configparser.ConfigParser()
        config.read(str(configpath))
        return config
1341626
def get_config(self):
        
        config = super(BoltzmannQPolicy, self).get_config()
        config['tau'] = self.tau
        config['clip'] = self.clip
        return config
1212673
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = Config(*args)
        return cls.__singleton
121221
def get_loss(self, pred: mx.sym.Symbol, labels: mx.sym.Symbol) -> mx.sym.Symbol:
        
        labels = mx.sym.reshape(labels, shape=(-1, 1))
        loss_value = self.loss_config.length_task_weight / 2 * mx.sym.square(pred - labels)
        loss_value = mx.sym.MakeLoss(data=loss_value,
                                     normalization='batch',
                                     name=self.name)
        return loss_value
997809
def get_config(self, key, default=None):
        ''' '''
        for conf in (self.config, self.app.conifg):
            if key in conf: return conf[key]
        return default
40717
def l1_loss(tensor, weight=1.0, scope=None):
  
  with tf.name_scope(scope, 'L1Loss', [tensor]):
    weight = tf.convert_to_tensor(weight,
                                  dtype=tensor.dtype.base_dtype,
                                  name='loss_weight')
    loss = tf.multiply(weight, tf.reduce_sum(tf.abs(tensor)), name='value')
    tf.add_to_collection(LOSSES_COLLECTION, loss)
    return loss
858197
public static function getInstance($config = null)
    {
        if (!self::$instance) {
            self::$instance = new self($config == null ? ConfigManager::getInstance()->getConfigHashmap() : $config);
        }
        return self::$instance;
    }
104619
def get_config(self, lesson=None):
        
        if not self.data:
            return {}
        if lesson is None:
            lesson = self.lesson_num
        lesson = max(0, min(lesson, self.max_lesson_num))
        config = {}
        parameters = self.data['parameters']
        for key in parameters:
            config[key] = parameters[key][lesson]
        return config