vfdev-5: @jasonkriss , @alykhantejani what do you think about if we extend testing grid to 
- py27, py35, py36
-  pytorch 0.4.1 , 1.0-preview

I would say this extends the testing by ~ 8 mins as in Tests travis allows to run on 5 machines in parallel and we have 6 cases.

alykhantejani: hmm, running on 1.0-preview is probably good. 8 minutes seems crazy long though. Do we need to test py35 and py36?
diff --git a/.travis.yml b/.travis.yml
index b50ef8a2..cb967eb1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,11 @@ language: python
 
 python:
   - "2.7"
-  - "3.5"
+  - "3.6"
+
+env:
+  - PYTORCH_PACKAGE=pytorch-cpu
+  - PYTORCH_PACKAGE=pytorch-nightly-cpu
 
 stages:
   - Lint check
@@ -20,7 +24,7 @@ before_install: &before_install
   - conda update -q conda
   # Useful for debugging any issues with conda
   - conda info -a
-  - conda create -q -n test-environment -c pytorch python=$TRAVIS_PYTHON_VERSION pytorch-cpu
+  - conda create -q -n test-environment -c pytorch python=$TRAVIS_PYTHON_VERSION $PYTORCH_PACKAGE
   - source activate test-environment
   - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install enum34; fi
   # Test contrib dependencies
@@ -106,6 +110,8 @@ jobs:
 
     - stage: Deploy
       python: "3.5"
+      env:
+        - PYTORCH_PACKAGE=pytorch-cpu
       if: tag IS present
 
       # Use previously defined before_install
diff --git a/ignite/_six.py b/ignite/_six.py
new file mode 100644
index 00000000..a68e8999
--- /dev/null
+++ b/ignite/_six.py
@@ -0,0 +1,31 @@
+# Copyright (c) 2010-2017 Benjamin Peterson
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+def with_metaclass(meta, *bases):
+    """Create a base class with a metaclass."""
+    # This requires a bit of explanation: the basic idea is to make a dummy
+    # metaclass for one level of class instantiation that replaces itself with
+    # the actual metaclass.
+    class metaclass(meta):
+
+        def __new__(cls, name, this_bases, d):
+            return meta(name, bases, d)
+    return type.__new__(metaclass, 'temporary_class', (), {})
diff --git a/ignite/metrics/metric.py b/ignite/metrics/metric.py
index 03b6e2c2..1f367029 100644
--- a/ignite/metrics/metric.py
+++ b/ignite/metrics/metric.py
@@ -1,11 +1,10 @@
 from abc import ABCMeta, abstractmethod
-
+from ignite._six import with_metaclass
 from ignite.engine import Events
-
 import torch
 
 
-class Metric(object):
+class Metric(with_metaclass(ABCMeta, object)):
     """
     Base class for all Metrics.
 
@@ -16,7 +15,6 @@ class Metric(object):
             you want to compute the metric with respect to one of the outputs.
 
     """
-    __metaclass__ = ABCMeta
 
     def __init__(self, output_transform=lambda x: x):
         self._output_transform = output_transform

Terminate on Nan tests fail with pytorch-nightly
https://travis-ci.org/vfdev-5/ignite/builds/458179313
diff --git a/tests/ignite/handlers/test_terminate_on_nan.py b/tests/ignite/handlers/test_terminate_on_nan.py
index 2c6a6044..b122b450 100644
--- a/tests/ignite/handlers/test_terminate_on_nan.py
+++ b/tests/ignite/handlers/test_terminate_on_nan.py
@@ -41,7 +41,7 @@ def test_terminate_on_nan_and_inf():
     assert trainer.should_terminate
     trainer.should_terminate = False
 
-    trainer.state.output = (10.0, 1.0 / torch.randint(0, 2, size=(4,)), 1.0)
+    trainer.state.output = (10.0, 1.0 / torch.randint(0, 2, size=(4,)).type(torch.float), 1.0)
     h(trainer)
     assert trainer.should_terminate
     trainer.should_terminate = False
@@ -50,7 +50,7 @@ def test_terminate_on_nan_and_inf():
     h(trainer)
     assert not trainer.should_terminate
 
-    trainer.state.output = 1.0 / torch.randint(0, 2, size=(4, 4))
+    trainer.state.output = 1.0 / torch.randint(0, 2, size=(4, 4)).type(torch.float)
     h(trainer)
     assert trainer.should_terminate
     trainer.should_terminate = False
@@ -95,7 +95,7 @@ def test_with_terminate_on_inf():
     torch.manual_seed(12)
 
     data = [1.0, 0.8, torch.rand(4, 4),
-            (1.0 / torch.randint(0, 2, size=(4,)), torch.tensor(1.234)),
+            (1.0 / torch.randint(0, 2, size=(4,)).type(torch.float), torch.tensor(1.234)),
             torch.rand(5), torch.asin(torch.randn(4, 4)), 0.0, 1.0]
 
     def update_fn(engine, batch):
diff --git a/tests/ignite/metrics/test_metric.py b/tests/ignite/metrics/test_metric.py
index 675169b8..371f2581 100644
--- a/tests/ignite/metrics/test_metric.py
+++ b/tests/ignite/metrics/test_metric.py
@@ -2,6 +2,7 @@ from ignite.metrics import Metric
 from ignite.engine import Engine, State
 import torch
 from mock import MagicMock
+from pytest import raises
 
 
 def test_no_transform():
@@ -113,3 +114,8 @@ def test_attach():
     assert m2.reset_count == 5
     assert m2.compute_count == 10
     assert m2.update_count == 50
+
+
+def test_abstract_class():
+    with raises(TypeError):
+        Metric()

pip install -e .
parse_log_pytest
pytest
numpy mock pytest codecov pytest-cov tqdm scikit-learn visdom torchvision tensorboardX gym
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
charset-normalizer==2.0.12
cloudpickle==2.2.1
codecov==2.1.13
coverage==6.2
dataclasses==0.8
decorator==4.4.2
gym==0.26.2
gym-notices==0.0.8
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
importlib-resources==5.4.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
joblib==1.1.1
jsonpatch==1.32
jsonpointer==2.3
mock==5.2.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
networkx==2.5.1
numpy==1.19.5
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
Pillow==8.4.0
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
protobuf==4.21.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
pytest-cov==4.0.0
-e git+https://github.com/pytorch/ignite.git@eeb63fbf3a27db985bf6029d970b26debd4e641b#egg=pytorch_ignite
requests==2.27.1
scikit-learn==0.24.2
scipy==1.5.4
six==1.17.0
tensorboardX==2.6.2.2
threadpoolctl==3.1.0
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
torch==1.10.1
torchvision==0.11.2
tornado==6.1
tqdm==4.64.1
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
visdom==0.2.4
websocket-client==1.3.1
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: ignite
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - charset-normalizer==2.0.12
      - cloudpickle==2.2.1
      - codecov==2.1.13
      - coverage==6.2
      - dataclasses==0.8
      - decorator==4.4.2
      - gym==0.26.2
      - gym-notices==0.0.8
      - idna==3.10
      - importlib-resources==5.4.0
      - joblib==1.1.1
      - jsonpatch==1.32
      - jsonpointer==2.3
      - mock==5.2.0
      - networkx==2.5.1
      - numpy==1.19.5
      - pillow==8.4.0
      - protobuf==4.21.0
      - pytest-cov==4.0.0
      - requests==2.27.1
      - scikit-learn==0.24.2
      - scipy==1.5.4
      - six==1.17.0
      - tensorboardx==2.6.2.2
      - threadpoolctl==3.1.0
      - tomli==1.2.3
      - torch==1.10.1
      - torchvision==0.11.2
      - tornado==6.1
      - tqdm==4.64.1
      - urllib3==1.26.20
      - visdom==0.2.4
      - websocket-client==1.3.1
prefix: /opt/conda/envs/ignite

tests/ignite/metrics/test_metric.py::test_abstract_class
tests/ignite/handlers/test_terminate_on_nan.py::test_terminate_on_nan_and_inf tests/ignite/handlers/test_terminate_on_nan.py::test_with_terminate_on_nan tests/ignite/handlers/test_terminate_on_nan.py::test_with_terminate_on_inf tests/ignite/handlers/test_terminate_on_nan.py::test_without_terminate_on_nan_inf tests/ignite/metrics/test_metric.py::test_no_transform tests/ignite/metrics/test_metric.py::test_transform tests/ignite/metrics/test_metric.py::test_no_grad tests/ignite/metrics/test_metric.py::test_attach
.travis.yml ignite/metrics/metric.py ignite/_six.py
.travis.yml ignite/metrics/metric.py ignite/_six.py