class_docstr: Implements the Model-Agnostic Meta-Learning algorithm for low data learning.
  
  The algorithm is described in Finn et al., "Model-Agnostic Meta-Learning for Fast
  Adaptation of Deep Networks" (https://arxiv.org/abs/1703.03400).  It is used for
  training models that can perform a variety of tasks, depending on what data they
  are trained on.  It assumes you have training data for many tasks, but only a small
  amount for each one.  It performs "meta-learning" by looping over tasks and trying
  to minimize the loss on each one *after* one or a few steps of gradient descent.
  That is, it does not try to create a model that can directly solve the tasks, but
  rather tries to create a model that is very easy to train.
  
  To use this class, create a subclass of MetaLearner that encapsulates the model
  and data for your learning problem.  Pass it to a MAML object and call fit().
  You can then use train_on_current_task() to fine tune the model for a particular
  task.
class_docstr_tok: ["Implements","the","Model-Agnostic","Meta-Learning","algorithm","for","low","data","learning",".","The","algorithm","is","described","in","Finn","et","al.",",","``","Model-Agnostic","Meta-Learning","for","Fast","Adaptation","of","Deep","Networks","''","(","https",":","\/\/arxiv.org\/abs\/1703.03400",")",".","It","is","used","for","training","models","that","can","perform","a","variety","of","tasks",",","depending","on","what","data","they","are","trained","on",".","It","assumes","you","have","training","data","for","many","tasks",",","but","only","a","small","amount","for","each","one",".","It","performs","``","meta-learning","''","by","looping","over","tasks","and","trying","to","minimize","the","loss","on","each","one","*","after","*","one","or","a","few","steps","of","gradient","descent",".","That","is",",","it","does","not","try","to","create","a","model","that","can","directly","solve","the","tasks",",","but","rather","tries","to","create","a","model","that","is","very","easy","to","train",".","To","use","this","class",",","create","a","subclass","of","MetaLearner","that","encapsulates","the","model","and","data","for","your","learning","problem",".","Pass","it","to","a","MAML","object","and","call","fit","(",")",".","You","can","then","use","train_on_current_task","(",")","to","fine","tune","the","model","for","a","particular","task","."]
docstr: This is called during fitting to compute the meta-loss (the loss after a
  few steps of optimization), and its gradient.
docstr_tok: ["This","is","called","during","fitting","to","compute","the","meta-loss","(","the","loss","after","a","few","steps","of","optimization",")",",","and","its","gradient","."]
code: def _compute_meta_loss(self, inputs, inputs2, variables):
      """This is called during fitting to compute the meta-loss (the loss after a
      few steps of optimization), and its gradient.
      """
      updated_variables = variables
      with tf.GradientTape() as meta_tape:
          for k in range(self.optimization_steps):
              with tf.GradientTape() as tape:
                  loss, _ = self.learner.compute_model(
                      inputs, updated_variables, True
                  )
              gradients = tape.gradient(loss, updated_variables)
              updated_variables = [
                  v if g is None else v - self.learning_rate * g
                  for v, g in zip(updated_variables, gradients)
              ]
          meta_loss, _ = self.learner.compute_model(
              inputs2, updated_variables, True
          )
      meta_gradients = meta_tape.gradient(meta_loss, variables)
      return meta_loss, meta_gradients
  
file_path: deepchem/deepchem/metalearning/maml.py
imports: import os
  import shutil
  import tempfile
  import time
  import tensorflow
  from deepchem.models.optimizers import Adam, GradientDescent
label_desc: Use image node_id 4 for calling the MAML obj's underlying member method code with example usage: obj._compute_meta_loss(inputs, inputs2, variables) and returns: meta_loss,  meta_gradients