code: def makeKeepDims_local(self, x, y, axis):
      if axis is None:
          newaxis = list(range(x.ndim))
      elif isinstance(axis, integer_types):
          if axis < 0:
              newaxis = [axis + x.type.ndim]
          else:
              newaxis = [axis]
      else:
          newaxis = []
          for a in axis:
              if a < 0:
                  a += x.type.ndim
              newaxis.append(a)
      i = 0
      new_dims = []
      for j, _ in enumerate(x.shape):
          if j in newaxis:
              new_dims.append("x")
          else:
              new_dims.append(i)
              i += 1
  
      return tensor.DimShuffle(y.type.broadcastable, new_dims)(y)
  
file_path: Theano/theano/tensor/tests/test_keepdims.py
imports: from __future__ import absolute_import, print_function, division
  import unittest
  import numpy
  from six import integer_types
  import theano
  from theano import tensor, function
  from theano.tests.unittest_tools import attr
label_desc: Use image node_id 1 for calling the TestKeepDims obj's underlying member method code with example usage: obj.makeKeepDims_local(x, y, axis) and returns: tensor