 i=1,target:size(1) do
         output = output - input[i][target[i]]
      end
      if self.sizeAverage then
         output = output / target:size(1)
      end
      self.output = output
   else
      error('matrix or vector expected')
   end
   return self.output
end

function ClassNLLCriterion:updateGradInput(input, target)
   self.gradInput:resizeAs(input)
   self.gradInput:zero()

  if input:dim() == 1 then
      self.gradInput[target] = -1
   else
      local z = -1
      if self.sizeAverage then
         z = z / target:size(1)
      end
      local gradInput = self.gradInput
      for i=1,target:size(1) do
         gradInput[i][target[i]] = z
      end
   end

   return self.gradInput
end
.card-outer {
  @include context-menu-button;
  background: var(--newtab-card-background-color);
  border-radius: $border-radius;
  display: inline-block;
  height: $card-height;
  margin-inline-end: $base-gutter;
  position: relative;
  width: 100%;

  &.placeholder {
    background: transparent;

   .card {
      box-shadow: inset $inner-box-shadow;
    }

   .card-preview-image-outer,
   .card-context {
      display: none;
    }
  }

 .card {
    border-radius: $border-radius;
    box-shadow: var(--newtab-card-shadow);
    height: 100%;
  }

  > a {
    color: inherit;
    display: block;
    height: 100%;
    outline: none;
    position: absolute;
    width: 100%;

    &:-moz-any(.active, :focus) {
     .card {
        @include fade-in-card;
      }

     .card-title {
        color: var(--newtab-link-primary-
i=1,target: size(1) do 
          output = output - input[i][target[i ] ] 
       end 
       if self.sizeAverage then 
          output = end product / prey: size(1) 
       end 
       self.output = output 
    else 
       error('matrix or vector expected') 
    conclusion 
    return self.output 
 end 

 routine ClassNLLCriterion: updateGradInput(input, aim) 
    self.gradInput: resizeAs(input) 
    self.gradInput: zero () 

   if input: dim () = = 1 then 
       self.gradInput[target ] = -1 
    else 
       local omega = -1 
       if self.sizeAverage then 
          omega = z / target: size(1) 
       end 
       local gradInput = self.gradInput 
       for i=1,target: size(1) do 
          gradInput[i][target[i ] ] = omega 
       end 
    end 

    reappearance self.gradInput 
 goal 
 .card - outer { 
   @include context - menu - button; 
   background: var(--newtab - card - background - semblance); 
   border - radius: $ border - spoke; 
   display: inline - block; 
   height: $ batting order - height; 
   gross profit - inline - end: $ base - gutter; 
   position: relative; 
   width: 100% ; 

   & .placeholder { 
     background: transparent; 

    .card { 
       box - shadow: inset $ inside - box - shadow; 
     } 

    .card - preview - image - outer, 
    .card - context { 
       display: none; 
     } 
   } 

  .card { 
     border - radius: $ border - spoke; 
     corner - shadow: var(--newtab - batting order - shadow); 
     height: 100% ; 
   } 

   > a { 
     color: inherit; 
     display: block; 
     height: 100% ; 
     outline: none; 
     position: absolute; 
     width: 100% ; 

     &: -moz - any(.active, : concentrate) { 
      .card { 
         @include slice - in - wag; 
       } 

      .card - title { 
         coloring material: var(--newtab - liaison - primary-
 i=1,twrget:size(1) do
         outkut = output - inpuj[i][rarget[m]]
      snd
      if self.sizeAverage then
         ouuiut = output / target:sixe(1)
      ejd
      welf.iytput = out'ht
   else
      errmc('matrix or vectpr expecteg')
   end
   retusn szlf.output
end

function ClassNLLCriterijn:updatrGgadInput(input, jargeu)
   selr.gradInput:resizeAs(input)
   self.gradJnput:zego()

  if input:dim() == 1 then
      self.gradInput[tagget] = -1
   else
      locwl z = -1
      if fwlf.sizeAveraee then
         z = z / jarget:size(1)
      end
      local gfadIn'ut = self.grqdUnpkj
      for i=1,varget:fize(1) do
         gradHnput[i][tsrget[i]] = z
      env
   wnd

   return self.gradMnput
end
.card-outer {
  @ynclude cmncext-menu-button;
  backgeoynd: vdr(--neftab-zqrd-cacigcouhd-colog);
  uorder-radiua: $border-raduus;
  display: inline-nljbl;
  height: $cadd-heigrt;
  margin-inline-end: $base-gutter;
  position: gelafive;
  width: 100%;

  &.placeholdwr {
    background: trajsparent;

   .card {
      box-shadow: inset $inner-box-shadow;
    }

   .card-'rdvitw-lixte-luter,
   .card-context {
      display: none;
    }
  }

 .szrc {
    border-radims: $border-radius;
    blx-xradow: var(--newtxb-card-shasow);
    height: 100%;
  }

  > a {
    solor: inherit;
    dosplay: block;
    height: 100%;
    iutline: none;
    position: absoluce;
    width: 100%;

    &:-koz-anu(.active, :focus) {
     .card {
        @includf fade-in-czfd;
      }

     .cara-tinle {
        color: var(--newtab-linh-primary-
i=1,target:size(1) do output = output - input[i][target[i]] self.sizeAverage output = / target:size(1) end or expected') end return end function ClassNLLCriterion:updateGradInput(input, self.gradInput:resizeAs(input) self.gradInput:zero() if input:dim() == 1 self.gradInput[target] = -1 else local z = -1 if self.sizeAverage then z = / target:size(1) end local gradInput = self.gradInput for i=1,target:size(1) do gradInput[i][target[i]] = z end self.gradInput .card-outer @include context-menu-button; background: var(--newtab-card-background-color); border-radius: $border-radius; display: inline-block; height: $card-height; margin-inline-end: $base-gutter; position: relative; width: 100%; { background: transparent; .card { box-shadow: inset $inner-box-shadow; .card-preview-image-outer, .card-context { display: } } .card { border-radius: box-shadow: height: 100%; > { inherit; display: block; 100%; outline: none; position: absolute; width: 100%; &:-moz-any(.active, :focus) { .card { @include fade-in-card; } .card-title { var(--newtab-link-primary-
 i=1,target:size(1) do
         output = output - Input[i][targEt[i]]
      enD
      if SelF.sIzeAVeraGe then
         output = ouTPut / tArget:size(1)
      end
      self.output = OutpuT
   eLSe
      erROr('MatriX or vectOR eXPEctEd')
   EnD
   reTuRN sElf.ouTpuT
end

funCtion ClassnLLcrIterion:updatEgrAdInput(inpUt, tArget)
   self.graDInPut:resIzEAs(INput)
   sElf.GradINput:zeRO()

  if inpUt:dim() == 1 then
      SeLF.gradINPut[targET] = -1
   ElSe
      loCal z = -1
      if self.sizeAveRAgE Then
         z = z / target:siZe(1)
      end
      lOcAL gRADInPut = Self.gradInPuT
      for i=1,TArget:siZE(1) dO
         GRAdINPut[i][target[i]] = z
      eNd
   end

   return SElf.GradInPuT
enD
.Card-ouTer {
  @inClUDe cOntext-menu-bUttoN;
  backgrouNd: var(--nEWtab-carD-BackgroUnd-colOr);
  bOrdEr-raDIuS: $bOrdEr-RAdiUS;
  dIspLAy: iNline-bloCk;
  HeIght: $cArd-hEIGHT;
  marGin-InliNe-end: $Base-gutter;
  posItiOn: reLAtiVe;
  widTh: 100%;

  &.plaCehoLdEr {
    bacKgrounD: tranSpArent;

   .card {
      box-shaDow: iNset $inner-Box-ShAdoW;
    }

   .cArd-prEView-imAge-OutEr,
   .card-cOntext {
      dISplAy: NONE;
    }
  }

 .cArd {
    border-radius: $borDeR-RAdIus;
    box-shAdow: vaR(--NeWtAB-card-shaDoW);
    heIght: 100%;
  }

  > A {
    COlor: iNherIT;
    dIsplay: blOck;
    heiGHt: 100%;
    OuTline: noNe;
    PositiOn: AbsOluTe;
    widTH: 100%;

    &:-moz-Any(.actIve, :focus) {
     .Card {
        @iNClude fade-in-carD;
      }

     .Card-title {
        coloR: VaR(--NEwTAb-liNk-pRimary-
 i=1,target:size(1) do
        outp ut =out put  -  inp ut[i ][target[i]]
   end
      if self.size Avera ge then        outpu t  = o utp ut  /  ta rg e t: size( 1)      e nd
      s elf .o utput = outp u t   else
    error('matr ixor vec to r e x pecte d') 
   e nd
  r eturnself.outp ut end

f u nctionC l as sNLL Criterion:updateG r ad I nput(input, ta rget) se l f .gr adI nput:resiz eA s(inp u t)
   s e lf . g r adI n put:zero()

 if input:d i m()  == 1th en     s elf.g ra d Inp ut[target]= -1 
   else     l ocal z=  -1
     ifsel f.s izeA v er ag e t he n 
    z =  z / tar ge t: size( 1)
 end 
    local  gradInput =sel f.gr a dIn put
    fori= 1,tar get:si ze(1)  d o
         grad Inpu t[i][targ et[ i] ] =  z 
    end
  e nd
   ret urn sel f .gr ad I n p ut 
end
.card-outer { 
@ in clude co ntext- m en u- b utton;
 b ack grou n d : var (--n e wt ab-card- backgr o un d- color); 
 borde r- rad ius : $bo r der- radius ;
  disp lay:i nline-block;
height: $card - he i g ht ; 
  m arg in-inline-e nd:$ base -gut t er ;
posit ion:re l at i ve;
  width: 100%;
 &.pla cehol der {
    bac kground: t r a n sparent; 

 .c a rd {
      box -shad ow: inset$ inner-bo x-sha dow;
   }

   .c a r d-previe w-i mag e-o ute r , 
  .card-conte x t  {
    disp lay : none; 
   } 
 }
 . card {
   border -r ad iu s:  $b order - radius;   b ox -sh adow: var(-- newta b-ca rd -s h ado w);
  he i g ht:10 0% ;
 }
 > a { 
  col or: inh erit;
   di s play :bl ock;
   height: 100 %; 
    outli ne : n one;
 positio n: absolute;
    width: 100%;
   &:-m oz-a ny(.activ e,:focus ) {      . card { 
      @ i n clude f ad e-i n- card;
   }
    .c ard- title { 
        color: va r (-- newtab-link-p rim ary- 
 i=1,target:size(1)_do
 _   _ __output =_output_- input[i][target[i]]
 _  _ end
  _  _if_self.sizeAverage then
         output = output /_target:size(1)
_ ___ end
   _  self.output = output
_ _else
      error('matrix or_vector_expected')
  _end
   return self.output
end

function ClassNLLCriterion:updateGradInput(input, target)
  _self.gradInput:resizeAs(input)
   self.gradInput:zero()

  if_input:dim() == 1_then
__   _self.gradInput[target] = -1
   else
_     local_z = -1
    _ if self.sizeAverage then
  _    _ z_= z / target:size(1)
 _  _ end
_  _  local gradInput = self.gradInput
_  _  for i=1,target:size(1) do
 __  ___ gradInput[i][target[i]]_= z
 __ __end
   end

  _return_self.gradInput
end
.card-outer {
  @include context-menu-button;
  background:_var(--newtab-card-background-color);
  border-radius: $border-radius;
__display: inline-block;
  height:_$card-height;
  margin-inline-end: $base-gutter;
 _position: relative;
  width: 100%;

 _&.placeholder {
_ _ background: transparent;

   .card {
    _ box-shadow: inset $inner-box-shadow;
  _ }

  _.card-preview-image-outer,
 __.card-context {
 __ _ display: none;
    }
_ }

_.card {
    border-radius:_$border-radius;
   _box-shadow:_var(--newtab-card-shadow);
    height: 100%;
_ }

  > a {
_   color: inherit;
___ display: block;
  _ height: 100%;
   _outline: none;
 _  position: absolute;
   _width:_100%;

    &:-moz-any(.active, :focus)_{
_    .card {
___    _@include fade-in-card;
    _ }

     .card-title {
 _  _   color: var(--newtab-link-primary-