docstr: This method reshapes the loss-related vectors back to the batch size. This is
  needed to record local metrics as the metrics need to be of batch size for
  generator model.
  
  Args:
      batch: batch being processed in this iteration.
      losses: losses we use for back propogate (shape: b' X 1), where b' <= b.
      metric_loss: loss we use for metrics (shape: b' X 1), where b' <= b.
      metric_correct: correct predictions from the model (shape: b' X 1), where b' <= b.
      metric_target_tokens: number of tokens in each examples for classification or generation tasks. (shape: b' X 1), where b' <= b.
      indices: indices of (either classification or generation) exs for which the loss was computed.
  
  Returns:
      A tuple of reshaped losses, metric_loss, metric_correct and num_target_tokens, all of shape: b X 1.
docstr_tok: ["This","method","reshapes","the","loss-related","vectors","back","to","the","batch","size",".","This","is","needed","to","record","local","metrics","as","the","metrics","need","to","be","of","batch","size","for","generator","model",".","Args",":","batch",":","batch","being","processed","in","this","iteration",".","losses",":","losses","we","use","for","back","propogate","(","shape",":","b","'","X","1",")",",","where","b","'","<","=","b.","metric_loss",":","loss","we","use","for","metrics","(","shape",":","b","'","X","1",")",",","where","b","'","<","=","b.","metric_correct",":","correct","predictions","from","the","model","(","shape",":","b","'","X","1",")",",","where","b","'","<","=","b.","metric_target_tokens",":","number","of","tokens","in","each","examples","for","classification","or","generation","tasks",".","(","shape",":","b","'","X","1",")",",","where","b","'","<","=","b.","indices",":","indices","of","(","either","classification","or","generation",")","exs","for","which","the","loss","was","computed",".","Returns",":","A","tuple","of","reshaped","losses",",","metric_loss",",","metric_correct","and","num_target_tokens",",","all","of","shape",":","b","X","1","."]
code: def _reshape_generator_tensor_to_record_metrics(
      self,
      batch,
      losses,
      metric_loss,
      metric_correct,
      metric_target_tokens,
      indices,
  ):
      """
      This method reshapes the loss-related vectors back to the batch size. This is
      needed to record local metrics as the metrics need to be of batch size for
      generator model.
  
      Args:
          batch: batch being processed in this iteration.
          losses: losses we use for back propogate (shape: b' X 1), where b' <= b.
          metric_loss: loss we use for metrics (shape: b' X 1), where b' <= b.
          metric_correct: correct predictions from the model (shape: b' X 1), where b' <= b.
          metric_target_tokens: number of tokens in each examples for classification or generation tasks. (shape: b' X 1), where b' <= b.
          indices: indices of (either classification or generation) exs for which the loss was computed.
  
      Returns:
          A tuple of reshaped losses, metric_loss, metric_correct and num_target_tokens, all of shape: b X 1.
      """
      val_id_shape = batch.valid_indices.shape
  
      reshaped_losses = self._reshape_tensor(
          val_id_shape, losses, indices
      )
      reshaped_metric_loss = self._reshape_tensor(
          val_id_shape, metric_loss, indices
      )
      reshaped_metric_correct = self._reshape_tensor(
          val_id_shape, metric_correct, indices
      )
      reshaped_num_target_tokens = self._reshape_tensor(
          val_id_shape, metric_target_tokens, indices
      )
  
      return (
          reshaped_losses,
          reshaped_metric_loss,
          reshaped_metric_correct,
          reshaped_num_target_tokens,
      )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from typing import Optional, Any, Dict, Tuple, Union, List
  from abc import abstractmethod
  from parlai.agents.transformer.modules import TransformerDecoderLayer
  from parlai.agents.fid.fid import FidAgent, FidModel
  from parlai.core.message import Message
  from parlai.core.metrics import AverageMetric
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.torch_generator_agent import PPLMetric
  from parlai.core.torch_agent import Batch, DictionaryAgent
  import parlai.utils.logging
  from projects.blenderbot2.agents.blenderbot2 import BlenderBot2FidAgent, BlenderBot2FidModel, T5BlenderBot2FidModel
  from parlai.agents.fid.fid import WizIntGoldDocRetrieverFiDAgent
  import parlai.agents.transformer.modules.ffn
  from parlai.agents.transformer.modules import LAYER_NORM_EPS
label_desc: Use image node_id 10 for calling the DirectorFidAgent obj's underlying member method code with example usage: obj._reshape_generator_tensor_to_record_metrics(batch, losses, metric_loss, metric_correct, metric_target_tokens, indices) and returns: reshaped_losses,  reshaped_metric_loss,  reshaped_metric_correct,  reshaped_num_target_tokens