class_docstr: Computes differentially private gradients as required by DP-SGD.
  This module can be used in place of GradVals, and automatically makes the optimizer differentially private.
class_docstr_tok: ["Computes","differentially","private","gradients","as","required","by","DP-SGD",".","This","module","can","be","used","in","place","of","GradVals",",","and","automatically","makes","the","optimizer","differentially","private","."]
docstr: Reshapes examples into microbatches.
  DP-SGD requires that per-example gradients are clipped and noised, however this can be inefficient.
  To speed this up, it is possible to clip and noise a microbatch of examples, at a sight cost to privacy.
  If speed is not an issue, the microbatch size should be set to 1.
  
  If x has shape [D0, D1, ..., Dn], the reshaped output will
  have shape [number_of_microbatches, microbatch_size, D1, ..., DN].
  
  Args:
      x: items to be reshaped.
  
  Returns:
      The reshaped items.
docstr_tok: ["Reshapes","examples","into","microbatches",".","DP-SGD","requires","that","per-example","gradients","are","clipped","and","noised",",","however","this","can","be","inefficient",".","To","speed","this","up",",","it","is","possible","to","clip","and","noise","a","microbatch","of","examples",",","at","a","sight","cost","to","privacy",".","If","speed","is","not","an","issue",",","the","microbatch","size","should","be","set","to","1",".","If","x","has","shape","[","D0",",","D1",",","...",",","Dn","]",",","the","reshaped","output","will","have","shape","[","number_of_microbatches",",","microbatch_size",",","D1",",","...",",","DN","]",".","Args",":","x",":","items","to","be","reshaped",".","Returns",":","The","reshaped","items","."]
code: def reshape_microbatch(self, x: JaxArray) -> JaxArray:
      """Reshapes examples into microbatches.
      DP-SGD requires that per-example gradients are clipped and noised, however this can be inefficient.
      To speed this up, it is possible to clip and noise a microbatch of examples, at a sight cost to privacy.
      If speed is not an issue, the microbatch size should be set to 1.
  
      If x has shape [D0, D1, ..., Dn], the reshaped output will
      have shape [number_of_microbatches, microbatch_size, D1, ..., DN].
  
      Args:
          x: items to be reshaped.
  
      Returns:
          The reshaped items.
      """
      s = x.shape
      return x.reshape(
          [s[0] // self.microbatch, self.microbatch, *s[1:]]
      )
  
file_path: objax/objax/privacy/dpsgd/gradient.py
imports: import functools
  from typing import Optional, Callable, Tuple
  import jax
  import jax.numpy
  from objax import random
  from objax.gradient import GradValues
  from objax.module import Function, Module, Vectorize
  from objax.typing import JaxArray
  from objax.util import repr_function, class_name
  from objax.variable import VarCollection
label_desc: Use image node_id 4 for calling the PrivateGradValues obj's underlying member method code with example usage: obj.reshape_microbatch(x) and returns: x