class_docstr: Executor is the object providing efficient symbolic and imperative graph
  execution and optimization.
  
  Examples
  --------
  >>> # typical approach to create an executor is to bind symbol
  >>> a = mx.sym.var('a')
  >>> b = mx.sym.var('b')
  >>> c = 2 * a + b
  >>> texec = c._bind(mx.cpu(), {'a': mx.nd.array([1,2]), 'b':mx.nd.array([2,3])})
class_docstr_tok: ["Executor","is","the","object","providing","efficient","symbolic","and","imperative","graph","execution","and","optimization",".","Examples","--","--","--","--",">",">",">","#","typical","approach","to","create","an","executor","is","to","bind","symbol",">",">",">","a","=","mx.sym.var","(","'","a","'",")",">",">",">","b","=","mx.sym.var","(","'","b","'",")",">",">",">","c","=","2","*","a","+","b",">",">",">","texec","=","c._bind","(","mx.cpu","(",")",",","{","'","a","'",":","mx.nd.array","(","[","1,2","]",")",",","'","b","'",":","mx.nd.array","(","[","2,3","]",")","}",")"]
code: def __init__(
      self,
      sym,
      device,
      args,
      args_grad,
      grad_req,
      aux_states,
      static_alloc=False,
  ):
      self.outputs = None
      self._input_names = sym.list_inputs()
      self._aux_names = sym.list_auxiliary_states()
      self._arg_names = sym.list_arguments()
      self._output_names = sym.list_outputs()
      self._device = device
      self._grad_req = grad_req
      self.static_alloc = static_alloc
      # grad_req
      self._requires_grad = False
      if isinstance(grad_req, dict):
          for k, v in grad_req.items():
              if k in self._input_names and v != "null":
                  self._requires_grad = True
      else:
          assert isinstance(grad_req, str)
          self._requires_grad = grad_req != "null"
  
      # args grad
      self._args_grad = args_grad
      if not self._args_grad:
          self._args_grad = None
  
      # args
      self._args = [None] * len(self._input_names)
      if isinstance(args, dict):
          for k, v in args.items():
              try:
                  i = self._input_names.index(k)
                  self._args[i] = v.copyto(device)
              # ignore provided arg which is not present in
              # input_names
              except ValueError:
                  pass
      else:
          assert isinstance(args, (list, tuple))
          for i, arg in enumerate(args):
              name = self._arg_names[i]
              index = self._input_names.index(name)
              self._args[index] = arg.copyto(device)
  
      # aux states
      if aux_states:
          if isinstance(aux_states, dict):
              for k, v in aux_states.items():
                  if k in self._aux_names:
                      i = self._input_names.index(k)
                      self._args[i] = v.copyto(device)
          else:
              assert isinstance(aux_states, (list, tuple))
              for i, v in enumerate(aux_states):
                  index = self._input_names.index(self._aux_names[i])
                  self._args[index] = v.copyto(device)
  
      # arg grad
      if self._args_grad:
          if isinstance(self._args_grad, dict):
              for k, g in self._args_grad.items():
                  try:
                      i = self._input_names.index(k)
                      # get req
                      if isinstance(grad_req, str):
                          req = grad_req
                      else:
                          assert isinstance(grad_req, dict)
                          req = grad_req[k]
                      if req != "null":
                          with self._device:
                              self._args[i].attach_grad(
                                  req, stype=g.stype
                              )
                              self._args[i].grad[:] = g
                  # ignore provided arg which is not present in
                  # input_names
                  except ValueError:
                      pass
          else:
              assert isinstance(self._args_grad, (list, tuple))
              for i, g in enumerate(self._args_grad):
                  # get req
                  if isinstance(grad_req, str):
                      req = grad_req
                  else:
                      assert isinstance(grad_req, dict)
                      req = grad_req[self._input_names[i]]
                  if req != "null":
                      with self._device:
                          self._args[i].attach_grad(req, stype=g.stype)
                          self._args[i].grad[:] = g
      self._cached_op = ndarray.CachedOp(
          sym, flags=[("static_alloc", self.static_alloc)]
      )
  
file_path: mxnet/python/mxnet/executor.py
imports: import numpy
  from .None import ndarray
label_desc: Use image node_id 1 to create a new Executor object  with example: obj = Executor(sym, device, args, args_grad, grad_req, aux_states, static_alloc)