class_docstr: Model-Agnostic Meta-Learning (MAML).
  
  Args:
      inner_algo (garage.torch.algos.VPG): The inner algorithm used for
          computing loss.
      env (Environment): An environment.
      policy (garage.torch.policies.Policy): Policy.
      sampler (garage.sampler.Sampler): Sampler.
      task_sampler (garage.experiment.TaskSampler): Task sampler.
      meta_optimizer (Union[torch.optim.Optimizer, tuple]):
          Type of optimizer.
          This can be an optimizer type such as `torch.optim.Adam` or a tuple
          of type and dictionary, where dictionary contains arguments to
          initialize the optimizer e.g. `(torch.optim.Adam, {'lr' : 1e-3})`.
      meta_batch_size (int): Number of tasks sampled per batch.
      inner_lr (float): Adaptation learning rate.
      outer_lr (float): Meta policy learning rate.
      num_grad_updates (int): Number of adaptation gradient steps.
      meta_evaluator (MetaEvaluator): A meta evaluator for meta-testing. If
          None, don't do meta-testing.
      evaluate_every_n_epochs (int): Do meta-testing every this epochs.
class_docstr_tok: ["Model-Agnostic","Meta-Learning","(","MAML",")",".","Args",":","inner_algo","(","garage.torch.algos.VPG",")",":","The","inner","algorithm","used","for","computing","loss",".","env","(","Environment",")",":","An","environment",".","policy","(","garage.torch.policies.Policy",")",":","Policy",".","sampler","(","garage.sampler.Sampler",")",":","Sampler",".","task_sampler","(","garage.experiment.TaskSampler",")",":","Task","sampler",".","meta_optimizer","(","Union","[","torch.optim.Optimizer",",","tuple","]",")",":","Type","of","optimizer",".","This","can","be","an","optimizer","type","such","as","`","torch.optim.Adam","`","or","a","tuple","of","type","and","dictionary",",","where","dictionary","contains","arguments","to","initialize","the","optimizer","e.g",".","`","(","torch.optim.Adam",",","{","'lr","'",":","1e-3","}",")","`",".","meta_batch_size","(","int",")",":","Number","of","tasks","sampled","per","batch",".","inner_lr","(","float",")",":","Adaptation","learning","rate",".","outer_lr","(","float",")",":","Meta","policy","learning","rate",".","num_grad_updates","(","int",")",":","Number","of","adaptation","gradient","steps",".","meta_evaluator","(","MetaEvaluator",")",":","A","meta","evaluator","for","meta-testing",".","If","None",",","do","n't","do","meta-testing",".","evaluate_every_n_epochs","(","int",")",":","Do","meta-testing","every","this","epochs","."]
docstr: Evaluate performance of this batch.
  
  Args:
      itr (int): Iteration number.
      all_samples (list[list[_MAMLEpisodeBatch]]): Two
          dimensional list of _MAMLEpisodeBatch of size
          [meta_batch_size * (num_grad_updates + 1)]
      loss_before (float): Loss before optimization step.
      loss_after (float): Loss after optimization step.
      kl_before (float): KL divergence before optimization step.
      kl (float): KL divergence after optimization step.
      policy_entropy (float): Policy entropy.
  
  Returns:
      float: The average return in last epoch cycle.
docstr_tok: ["Evaluate","performance","of","this","batch",".","Args",":","itr","(","int",")",":","Iteration","number",".","all_samples","(","list","[","list","[","_MAMLEpisodeBatch","]","]",")",":","Two","dimensional","list","of","_MAMLEpisodeBatch","of","size","[","meta_batch_size","*","(","num_grad_updates","+","1",")","]","loss_before","(","float",")",":","Loss","before","optimization","step",".","loss_after","(","float",")",":","Loss","after","optimization","step",".","kl_before","(","float",")",":","KL","divergence","before","optimization","step",".","kl","(","float",")",":","KL","divergence","after","optimization","step",".","policy_entropy","(","float",")",":","Policy","entropy",".","Returns",":","float",":","The","average","return","in","last","epoch","cycle","."]
code: def _log_performance(
      self,
      itr,
      all_samples,
      loss_before,
      loss_after,
      kl_before,
      kl,
      policy_entropy,
  ):
      """Evaluate performance of this batch.
  
      Args:
          itr (int): Iteration number.
          all_samples (list[list[_MAMLEpisodeBatch]]): Two
              dimensional list of _MAMLEpisodeBatch of size
              [meta_batch_size * (num_grad_updates + 1)]
          loss_before (float): Loss before optimization step.
          loss_after (float): Loss after optimization step.
          kl_before (float): KL divergence before optimization step.
          kl (float): KL divergence after optimization step.
          policy_entropy (float): Policy entropy.
  
      Returns:
          float: The average return in last epoch cycle.
  
      """
      tabular.record("Iteration", itr)
  
      name_map = None
      if hasattr(self._env, "all_task_names"):
          names = self._env.all_task_names
          name_map = dict(zip(names, names))
  
      rtns = log_multitask_performance(
          itr,
          EpisodeBatch.from_list(
              env_spec=self._env.spec,
              paths=[
                  path
                  for task_paths in all_samples
                  for path in task_paths[self._num_grad_updates].paths
              ],
          ),
          discount=self._inner_algo.discount,
          name_map=name_map,
      )
  
      with tabular.prefix(self._policy.name + "/"):
          tabular.record("LossBefore", loss_before)
          tabular.record("LossAfter", loss_after)
          tabular.record("dLoss", loss_before - loss_after)
          tabular.record("KLBefore", kl_before)
          tabular.record("KLAfter", kl)
          tabular.record("Entropy", policy_entropy)
  
      return np.mean(rtns)
  
imports: import collections
  import copy
  from dowel import tabular
  import numpy
  import torch
  from garage import _Default, EpisodeBatch, log_multitask_performance, make_optimizer
  from garage.np import discount_cumsum
  from garage.torch import update_module_params
  from garage.torch._functions import np_to_torch, zero_optim_grads
  from garage.torch.optimizers import ConjugateGradientOptimizer, DifferentiableSGD
label_desc: Use image node_id 14 for calling the MAML obj's underlying member method code with example usage: obj._log_performance(itr, all_samples, loss_before, loss_after, kl_before, kl, policy_entropy) and returns: np